tools/ holds model tools. These 15 files register none: they launch and
track Chromium, hold the per-task browser sessions and run the CDP
supervisor the browser tools call. They move to a new root package:
tools/browser_session*.py -> browser/session*.py
tools/browser_launcher{,_holders} -> browser/launcher{,_holders}.py
tools/browser_lightpanda.py -> browser/lightpanda.py
tools/browser_supervisor*.py -> browser/supervisor*.py
tools/browser_real_profile_logins -> browser/real_profile_logins.py
tools/bot_desktop/browser.py -> browser/desktop_profile.py
browser/__init__.py is a docstring only. tools/browser_tool.py and every
tool file stay. 38 tests and one helper move to tests/browser/; its
conftest.py imports the autouse fixtures of tests/tools/conftest.py they
ran under.
Old-path files, each a MOVES key, a REQUIRED_NAMES row and a file
written by scripts/move/generate_shims.py:
- tools.browser_supervisor and tools.browser_supervisor_capture are on
the published plugin API (hermes_cli/data/plugin_api.json), so a
plugin's import gives the same module object.
- tools.browser_session and tools.browser_session_cloud are imported
inside functions on every turn by a process started on v0.22.7 to
v0.23.5 (the per-turn browser cleanup), which keeps running its old
code after an update swaps the checkout.
Function bodies are unchanged and every import stays where it was.
Loggers follow their modules: every moved file keeps
getLogger(__name__), and the two literal supervisor loggers name
browser.supervisor. browser joins the tools entry of
hermes_logging.COMPONENT_PREFIXES, so `hermes logs --component tools`
shows the same lines. browser also joins packages.find,
FIRST_PARTY_MODULE_ROOTS, _KNOWN_LOGGER_ROOTS, the plugin isolation
audit, six check scripts, the P33 profile-scope pattern, the gateway's
stop-path preload list and the test fixtures that list root packages.
The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; split imports, imports inside child-process code
strings, boundary-lint baseline keys, two resolution-allowlist rows and
docs globs were fixed by hand.
Pinned catalog plugins import these moved modules by the old name, so each has a key in
hermes_agent/compat/moves.py and the plugin guide lists it with the release
that may remove it (no earlier than v0.27.0):
tools.browser_session_cdp
tools.browser_session_lifecycle
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
"""Regression tests for the browser command-timeout cache (#14331).
|
|
|
|
Before the fix the cache could be marked resolved while still holding ``None``, so a caller evaluating
|
|
``max(timeout, floor)`` crashed with ``TypeError``. ``browser_session_cloud.command_timeout`` (the floor
|
|
of the Chromium launch timeout) must answer an int even when the config read fails.
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from browser import session_cloud as browser_session_cloud
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _fresh_cache():
|
|
browser_session_cloud.reset_caches()
|
|
yield
|
|
browser_session_cloud.reset_caches()
|
|
|
|
|
|
class TestGetCommandTimeoutRace:
|
|
def test_returns_default_when_config_read_raises(self):
|
|
"""If config reading blows up, we still return an int (not None), and the memoised value is that int."""
|
|
with patch("hermes_cli.config_effective.load_user_config_effective", side_effect=OSError("boom")):
|
|
result = browser_session_cloud.command_timeout()
|
|
|
|
assert isinstance(result, int)
|
|
assert result == browser_session_cloud.DEFAULT_COMMAND_TIMEOUT
|
|
# The cached slot must hold the int, never None.
|
|
assert browser_session_cloud.command_timeout() == browser_session_cloud.DEFAULT_COMMAND_TIMEOUT
|