Skip to content

Fix async fixture autouse=True support (issue #123) - #159

Open
VedantBhayani wants to merge 8 commits into
python-trio:masterfrom
VedantBhayani:master
Open

VedantBhayani wants to merge 8 commits into
python-trio:masterfrom
VedantBhayani:master

Conversation

@VedantBhayani

Copy link
Copy Markdown

Fixes issue #123 - async fixtures with autouse=True were not being automatically applied to tests.

Changes

  • pytest_trio/plugin.py: Detect autouse fixtures via fixturedef._autouse, store on test item, include in nursery execution, register dependencies
  • pytest_trio/_tests/test_autouse.py: New test file with 6 comprehensive tests covering:
    • autouse=True with @pytest.mark.trio
    • autouse=True in trio_mode = true
    • Multiple autouse async fixtures
    • Autouse async fixture with dependency
    • Autouse async yield fixture
    • Autouse fixture with regular test dependency

Testing

  • All 63 tests pass (including 6 new autouse tests)
  • 2 pre-existing xfails unchanged
  • Works with both @pytest.mark.trio and trio_mode = true configurations

Fixes #123.

- In handle_fixture, detect autouse fixtures (via fixturedef._autouse) and store
  them on the test item (request.node._trio_autouse_fixtures)
- In _bootstrap_fixtures_and_run_test, add autouse fixtures to test's kwargs
  so test waits for them, and include them in the nursery for execution
- Filter out autouse fixture kwargs when calling the test function
- Add comprehensive tests for autouse async fixtures
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.

Async fixtures do not support autouse=True

1 participant