test: declare pytest-asyncio so the async attach tests actually run - #23
Open
FritzHeider wants to merge 1 commit into
Open
test: declare pytest-asyncio so the async attach tests actually run#23FritzHeider wants to merge 1 commit into
FritzHeider wants to merge 1 commit into
Conversation
tests/test_browser_attach.py has six @pytest.mark.asyncio tests, but pytest-asyncio was never declared in the dev extra. On a clean `pip install -e '.[dev]'` all six error out with "async def functions are not natively supported" and the mark warns as unknown. Declaring the dependency makes them run, which surfaces a real failure: close_browser() clears self._process, so asserting on browser._process.terminate afterwards dereferences None. Capture the mock first, and also assert kill() wasn't called — attach mode must leave the user's browser alone by either path.
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.
Problem
tests/test_browser_attach.pyhas six@pytest.mark.asynciotests, butpytest-asynciois not declared in thedevextra. After a cleanpip install -e '.[dev]', all six fail:So the entire attach-mode test surface — WS URL resolution, port polling, and the guarantee that attach mode never kills the user's browser — is not currently being exercised.
What declaring it revealed
With
pytest-asyncioinstalled, five of the six pass and one genuinely fails:close_browser()clearsself._process, so readingbrowser._process.terminateafter the call dereferencesNone. The assertion could never have run. Capturing the mock in a local before the call fixes it, and I addedkill.assert_not_called()alongside — attach mode should leave the user's browser alone by either path.Changes
pyproject.toml: addpytest-asyncio>=1.0.0to thedevextra, and setasyncio_default_fixture_loop_scope = "function"to silence the unset-default deprecation warning.uv.lock: regenerated for the new dependency.tests/test_browser_attach.py: capture the process mock beforeclose_browser(), and assertkill()wasn't called either.Result
pytest tests/goes from 1 failed, 19 passed to 20 passed.Branches off current
main; no other files touched.