Skip to content

Test: declare the computer_use tool_context fixture with pytest_asyncio.fixture - #177

Open
AmaadMartin wants to merge 1 commit into
mainfrom
fix/computer-use-pytest-asyncio-fixture
Open

Test: declare the computer_use tool_context fixture with pytest_asyncio.fixture#177
AmaadMartin wants to merge 1 commit into
mainfrom
fix/computer-use-pytest-asyncio-fixture

Conversation

@AmaadMartin

@AmaadMartin AmaadMartin commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

  1. Link to an existing issue (if applicable):

N/A

  1. Or, if no issue exists, describe the change:

Problem: TestComputerUseTool.tool_context is a coroutine fixture declared with @pytest.fixture. It only works because this repo sets asyncio_mode = "auto" in pyproject.toml. Under pytest --asyncio-mode=strict, pytest-asyncio does not adopt the fixture, so its 9 consumers error at setup with "requested an async fixture 'tool_context', with no plugin or hook that handled it".

Solution: I declared the fixture with @pytest_asyncio.fixture. The module now states its own async intent instead of depending on pyproject.toml. This matches tests/unittests/tools/test_local_environment.py and the two tests/unittests/tools/environment/ modules, which already use @pytest_asyncio.fixture. pytest-asyncio is already a declared test dependency (pyproject.toml), so no dependency changes.

Collision check: I listed the 100 open PRs on this fork and checked every plausibly adjacent one. Only #168 touches this file, and it removes an unused function-local import about 460 lines away. There is no overlap, so this branch starts from main.

Testing Plan

Environment: pytest 9.1.1, pytest-asyncio 1.4.0, Python 3.13.14.

Before the change:

Command Result
pytest tests/unittests/tools/computer_use -q 74 passed
pytest tests/unittests/tools/computer_use -q --asyncio-mode=strict 65 passed, 9 errors

After the change:

Command Result
pytest tests/unittests/tools/computer_use -q 74 passed
pytest tests/unittests/tools/computer_use -q --asyncio-mode=strict 74 passed
pytest tests/unittests/tools/computer_use -q --asyncio-mode=strict -W error::pytest.PytestWarning 74 passed

The last run proves that no PytestWarning replaced the setup error.

Mutation check: I reverted the decorator to @pytest.fixture and kept the new import. Strict mode returned to 65 passed, 3 warnings, 9 errors, with all 9 errors naming tool_context. The changed line is what fixes the failure.

Static check: an AST scan for async def functions decorated with @pytest.fixture reports zero hits in tests/unittests/tools/computer_use.

Formatting: isort==8.0.1 and pyink==25.12.0 (the pinned pre-commit versions) both leave the file unchanged.

This change adds no product code, so there is no new line to cover. The coverage obligation is met by the 9 previously-erroring tests now executing and passing in both asyncio modes.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Manual End-to-End (E2E) Tests:

Run the two commands below from the repo root. They must report the same counts and no errors.

pytest tests/unittests/tools/computer_use -q
pytest tests/unittests/tools/computer_use -q --asyncio-mode=strict

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

CI note

All test jobs pass: Unit Tests on Python 3.10 to 3.14, A2A v0.3 Tests on 3.10 to 3.14, and Mypy Check on 3.10 to 3.13.

Pre-commit Linter fails on the update-constraints hook. That hook regenerates constraints-*.txt with a fresh --exclude-newer date, so it fails on every run. It already fails on main at this branch's base commit 352d11d3. This diff touches no pyproject.toml and no constraints file, so the failure is unrelated. PR #163 covers that hook.

…io.fixture

tool_context is a coroutine fixture declared with @pytest.fixture. It only
works because the repo sets asyncio_mode = auto in pyproject.toml. Under
pytest --asyncio-mode=strict, pytest-asyncio does not adopt it and its 9
consumers in TestComputerUseTool error at setup.

Declaring it with @pytest_asyncio.fixture states the intent in the module
itself, matching tests/unittests/tools/test_local_environment.py and the two
tests/unittests/tools/environment/ modules.
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