Skip to content

test: declare pytest-asyncio so the async attach tests actually run - #23

Open
FritzHeider wants to merge 1 commit into
Jeomon:mainfrom
FritzHeider:fix/pytest-asyncio-dev-dep
Open

test: declare pytest-asyncio so the async attach tests actually run#23
FritzHeider wants to merge 1 commit into
Jeomon:mainfrom
FritzHeider:fix/pytest-asyncio-dev-dep

Conversation

@FritzHeider

Copy link
Copy Markdown
Contributor

Problem

tests/test_browser_attach.py has six @pytest.mark.asyncio tests, but pytest-asyncio is not declared in the dev extra. After a clean pip install -e '.[dev]', all six fail:

FAILED tests/test_browser_attach.py::test_resolve_ws_url_attach_uses_devtools_active_port
  - Failed: async def functions are not natively supported.
... (6 total)
PytestUnknownMarkWarning: Unknown pytest.mark.asyncio - is this a typo?

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-asyncio installed, five of the six pass and one genuinely fails:

FAILED tests/test_browser_attach.py::test_close_browser_attach_does_not_terminate_process
  - AttributeError: 'NoneType' object has no attribute 'terminate'

close_browser() clears self._process, so reading browser._process.terminate after the call dereferences None. The assertion could never have run. Capturing the mock in a local before the call fixes it, and I added kill.assert_not_called() alongside — attach mode should leave the user's browser alone by either path.

Changes

  • pyproject.toml: add pytest-asyncio>=1.0.0 to the dev extra, and set asyncio_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 before close_browser(), and assert kill() wasn't called either.

Result

pytest tests/ goes from 1 failed, 19 passed to 20 passed.

Branches off current main; no other files touched.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant