Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ Homepage = "https://github.com/browser-use/browser-harness"
Repository = "https://github.com/browser-use/browser-harness"
Issues = "https://github.com/browser-use/browser-harness/issues"

# Dev tooling lives in the default `dev` group so `uv run pytest` resolves it
# from the persistent project env. Running `uv run --with pytest pytest` instead
# builds a fresh ephemeral overlay venv on every cold cache (~2.8s vs ~0.5s).
[dependency-groups]
dev = [
"pytest>=8",
]

[tool.setuptools]
package-dir = {"" = "src"}

Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
from browser_harness import run


@pytest.fixture(autouse=True)
def _isolate_browser_env(monkeypatch):
"""run.main()'s cloud-bootstrap guard reads process env directly
(BROWSER_USE_API_KEY, BU_AUTOSPAWN, BU_CDP_URL, BU_CDP_WS). A dev box or CI
runner that exports any of these leaks it into every test — e.g. an ambient
BU_CDP_URL (a running local Chrome debug endpoint) makes
_explicit_cdp_configured() true and silently blocks the bootstrap these
tests assert on, and an ambient BU_AUTOSPAWN + key would fire the real
start_remote_daemon in tests that don't mock it. Start every test from a
clean slate; tests that need a var set it themselves."""
for var in ("BROWSER_USE_API_KEY", "BU_AUTOSPAWN", "BU_CDP_URL", "BU_CDP_WS"):
monkeypatch.delenv(var, raising=False)


def test_stdin_executes_code():
stdout = StringIO()
fake_stdin = StringIO("print('hello from stdin')")
Expand Down