-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bumps pytest
and pytest-asyncio
to the latest versions
#15523
Conversation
We were blocked from upgrading `pytest` because we were redefining the `event_loop` fixture, which has been deprecated for some time in `pytest-asyncio`. Here we remove that fixture and set the appropriate configuration per their [docs][1]: * Automatically marks all async tests as being marked with the `asyncio` fixture set to `loop_scope="session" * Make the default fixture loop scope `session` as well (in `setup.cfg`) * In the case where we need to switch to a different policy, like for Windows support, override the `event_loop_policy` fixture One issue emerged here, where any test that called `asyncio.run` or `anyio.run` would leave the test clearing the event loop from the `'MainThread'`, thus poisoning the environment for all subsequent tests. Adding a fixture that restores the session-level `pytest-asyncio` event loop after each test function prevents that issue. Fixes #14559 [1]: https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/run_session_tests_in_same_loop.html
@@ -1,24 +0,0 @@ | |||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discovered this file was a no-op (there is a fixture, but no tests, so I just removed the whole thing)
pytest > 7, < 9 | ||
pytest-asyncio >= 0.18.2, != 0.22.0, < 0.23.0 # Cannot override event loop in 0.23.0. See https://github.com/pytest-dev/pytest-asyncio/issues/706 for more details. | ||
pytest >= 8.3 | ||
pytest-asyncio >= 0.24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅
CodSpeed Performance ReportMerging #15523 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
Have you considered getting rid of the use of |
We were blocked from upgrading
pytest
because we were redefining theevent_loop
fixture, which has been deprecated for some time inpytest-asyncio
. Here we remove that fixture and set the appropriateconfiguration per their docs:
asyncio
fixtureset to `loop_scope="session"
session
as well (insetup.cfg
)support, override the
event_loop_policy
fixtureOne issue emerged here, where any test that called
asyncio.run
oranyio.run
would leave the test clearing the event loop from the
'MainThread'
, thuspoisoning the environment for all subsequent tests. Adding a fixture that
restores the session-level
pytest-asyncio
event loop after each test functionprevents that issue.
Fixes #14559
Checklist
<link to issue>
"mint.json
.