Skip to content

Support pytest 9.2 by moving to pytest-asyncio 1.x - #89

Merged
wbarnha merged 1 commit into
faust-streaming:masterfrom
itzzdev09:pytest-asyncio-1x
Nov 26, 2026
Merged

wbarnha merged 1 commit into
faust-streaming:masterfrom
itzzdev09:pytest-asyncio-1x

Conversation

@itzzdev09

Copy link
Copy Markdown

Note: Before submitting this pull request, please review our contributing
guidelines
.

Description

Follow-up requested by @wbarnha in #88: the test suite fails on master with pytest 9.2.0.

pytest-asyncio==0.21.1 reads FixtureManager._arg2fixturedefs, which pytest 9.2.0 removed, so every test module errors at collection:

AttributeError: 'FixtureManager' object has no attribute '_arg2fixturedefs'

Changes:

  • requirements-tests.txt: pytest-asyncio==0.21.1 -> pytest-asyncio>=1.0.0.
  • pytest-asyncio 1.0 removed the event_loop fixture. The shared loop fixture in tests/conftest.py is now an async fixture returning the running loop, and test_ServiceThread uses loop instead of event_loop.
  • pyproject.toml: set asyncio_default_fixture_loop_scope = "function" to silence pytest-asyncio's deprecation warning about the unset default.
  • tests/unit/utils/test_loops.py: 0.21's event_loop teardown happened to close the loop that mode.utils.loops.get_event_loop() caches per thread, so the cache was ignored afterwards. 1.x leaves that loop open, and two get_event_loop tests then got a stale loop from earlier tests. An autouse fixture clears the cache before each test in that module.

No library code changes.

Tested locally (Python 3.12): pytest tests/unit tests/functional gives 856 passed with pytest 9.2.0 + pytest-asyncio 1.5.0, also in random order, and with pytest 8.4.2. ruff check / ruff format --check pass.

pytest-asyncio 0.21.1 reads FixtureManager._arg2fixturedefs, which
pytest 9.2.0 removed, so every test module errors at collection.

- Require pytest-asyncio>=1.0.0.
- pytest-asyncio 1.0 removed the event_loop fixture: the shared loop
  fixture now returns the running loop from an async fixture, and
  test_ServiceThread uses it instead of event_loop.
- Set asyncio_default_fixture_loop_scope to silence the deprecation
  warning about the unset default.
- 0.21's event_loop teardown closed the loop that get_event_loop()
  caches per thread; 1.x leaves it open, so the get_event_loop tests
  saw a stale loop from earlier tests.  Clear the cache before each
  test in test_loops.py.
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.78%. Comparing base (5994429) to head (93eba98).
⚠️ Report is 94 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
- Coverage   94.86%   94.78%   -0.08%     
==========================================
  Files          28       28              
  Lines        4031     4142     +111     
  Branches      449      455       +6     
==========================================
+ Hits         3824     3926     +102     
+ Misses        188      152      -36     
- Partials       19       64      +45     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@itzzdev09 itzzdev09 mentioned this pull request Nov 26, 2026
@wbarnha
wbarnha merged commit 10bbafd into faust-streaming:master Nov 26, 2026
13 of 14 checks passed
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.

2 participants