Repository navigation
Support pytest 9.2 by moving to pytest-asyncio 1.x - #89
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Merged
wbarnha
approved these changes
Nov 26, 2026
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.
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.1readsFixtureManager._arg2fixturedefs, which pytest 9.2.0 removed, so every test module errors at collection:Changes:
requirements-tests.txt:pytest-asyncio==0.21.1->pytest-asyncio>=1.0.0.event_loopfixture. The sharedloopfixture intests/conftest.pyis now an async fixture returning the running loop, andtest_ServiceThreadusesloopinstead ofevent_loop.pyproject.toml: setasyncio_default_fixture_loop_scope = "function"to silence pytest-asyncio's deprecation warning about the unset default.tests/unit/utils/test_loops.py: 0.21'sevent_loopteardown happened to close the loop thatmode.utils.loops.get_event_loop()caches per thread, so the cache was ignored afterwards. 1.x leaves that loop open, and twoget_event_looptests 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/functionalgives 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 --checkpass.