test(run): isolate cloud-bootstrap tests from ambient env; add pytest dev group#544
Open
Adekunes wants to merge 2 commits into
Open
test(run): isolate cloud-bootstrap tests from ambient env; add pytest dev group#544Adekunes wants to merge 2 commits into
Adekunes wants to merge 2 commits into
Conversation
test_cloud_bootstrap_on_headless_server failed on any box that exports BU_CDP_URL (a running local Chrome debug endpoint): run.main()'s bootstrap guard reads process env directly, so the ambient value made _explicit_cdp_configured() true and suppressed the start_remote_daemon call the test asserts on. Add an autouse fixture that clears BROWSER_USE_API_KEY, BU_AUTOSPAWN, BU_CDP_URL and BU_CDP_WS before each test, so every test starts from a clean slate and sets only the vars it needs. Also hardens the non-cloud tests, which would otherwise fire the real start_remote_daemon on a box exporting BU_AUTOSPAWN + key. Source logic was correct; only the test's env assumption was stale. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Tests were being run via `uv run --with pytest pytest`, which layers pytest into a fresh ephemeral overlay venv on every cold uv cache (~2.8s) instead of the persistent project env (~0.5s). Declaring pytest in the default `dev` group lets `uv run pytest ...` resolve it from the synced project env, so repeat runs stay sub-second. uv.lock is gitignored, so only pyproject changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two small, independent test/tooling improvements to
run.py's cloud-bootstrap coverage.1. Isolate the cloud-bootstrap tests from ambient
BU_*envrun.main()'s auto-bootstrap guard reads process env directly(
BROWSER_USE_API_KEY,BU_AUTOSPAWN,BU_CDP_URL,BU_CDP_WS). Any dev boxor CI runner that exports one of these leaks it into the tests:
test_cloud_bootstrap_on_headless_serverfails on a machine with an ambientBU_CDP_URL(e.g. a running local Chrome debug endpoint) — it makes_explicit_cdp_configured()return true and silently suppresses thestart_remote_daemoncall the test asserts on.test_stdin_executes_code) don't mockstart_remote_daemon, so a box exportingBU_AUTOSPAWN+ a key would firethe real thing.
Add an autouse fixture that clears those four vars before each test, so every
test starts hermetic and only sets what it needs. Source logic is unchanged —
this only fixes the tests' env assumptions.
2. Add
pytestto adevdependency-groupRunning the suite via
uv run --with pytest pytestbuilds a fresh ephemeraloverlay venv on every cold uv cache (~2.8s) instead of the persistent project
env (~0.5s). Declaring
pytestin the defaultdevgroup letsuv run pytestresolve it from the synced project env, keeping repeat runs sub-second.
uv.lockis gitignored, so onlypyproject.tomlchanges.Testing
uv run pytest tests/unit -q→ all green on top of currentmain.🤖 Generated with Claude Code
Summary by cubic
Isolates cloud-bootstrap tests from ambient env vars and adds
pytestto thedevdependency group to prevent flaky tests and speed up local runs.Bug Fixes
Dependencies
pytest>=8to thedevgroup.uv run pytestto use the persistent project env for faster repeat runs.Written for commit aa4e15a. Summary will update on new commits.