Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Refactor message_manager tests to use a temporary file system path, enhancing isolation and reliability of test cases.

Magnus Müller2ee381d28381
diff --git a/browser_use/agent/message_manager/tests.py b/browser_use/agent/message_manager/tests.py
index 8c74e99a6..d8293788e 100644
--- a/browser_use/agent/message_manager/tests.py
+++ b/browser_use/agent/message_manager/tests.py
@@ -21,6 +21,13 @@ from browser_use.filesystem.file_system import FileSystem
def message_manager(request: pytest.FixtureRequest):
task = 'Test task'
action_descriptions = 'Test actions'
+
+ import os
+ import tempfile
+ import uuid
+
+ base_tmp = tempfile.gettempdir() # e.g., /tmp on Unix
+ file_system_path = os.path.join(base_tmp, str(uuid.uuid4()))
return MessageManager(
task=task,
system_message=SystemMessage(content=action_descriptions),
@@ -29,7 +36,7 @@ def message_manager(request: pytest.FixtureRequest):
estimated_characters_per_token=3,
image_tokens=800,
),
- file_system=FileSystem(),
+ file_system=FileSystem(file_system_path),
)
diff --git a/tests/ci/test_agent_sensitive_data.py b/tests/ci/test_agent_sensitive_data.py
index 0649fdb83..d2b8f664a 100644
--- a/tests/ci/test_agent_sensitive_data.py
+++ b/tests/ci/test_agent_sensitive_data.py
@@ -22,12 +22,18 @@ def registry():
@pytest.fixture
def message_manager():
+ import os
+ import tempfile
+ import uuid
+
+ base_tmp = tempfile.gettempdir() # e.g., /tmp on Unix
+ file_system_path = os.path.join(base_tmp, str(uuid.uuid4()))
return MessageManager(
task='Test task',
system_message=SystemMessage(content='System message'),
settings=MessageManagerSettings(),
state=MessageManagerState(),
- file_system=FileSystem(),
+ file_system=FileSystem(file_system_path),
)