You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pytest-asyncio v0.24 supports independent event-loop scopes and fixture caching scopes. This is great, thank you. However, I had some confusion while working with this. I thought I'd share in case there's an elegant solution I've not spotted.
I've understood asyncio_default_fixture_loop_scope was intended to relieve such boilerplate on the fixtures, but is there something similar possible for the tests themselves? I know I could write a hook to add this marker to the tests, but my gut feeling says this magic would confuse later. On the other hand, I could imagine some config like asyncio_default_test_loop_scope... is there something neat I've missed?
The text was updated successfully, but these errors were encountered:
pytest-asyncio v0.24 supports independent event-loop scopes and fixture caching scopes. This is great, thank you. However, I had some confusion while working with this. I thought I'd share in case there's an elegant solution I've not spotted.
The following works fine:
and with a minor change I've convinced myself that
another_fixture
really is function-scoped. All good.However, if I have
pyproject.toml
containing:my initial (hopeful) expectation was that I would not need to write
loop_scope="session"
everywhere, but this is mistaken:with error:
Of course, the solution is to omit
loop_scope="session"
only the fixtures, but keep it on the test function itself like:but in a suite of many tests, it's boilerplate.
I've understood
asyncio_default_fixture_loop_scope
was intended to relieve such boilerplate on the fixtures, but is there something similar possible for the tests themselves? I know I could write a hook to add this marker to the tests, but my gut feeling says this magic would confuse later. On the other hand, I could imagine some config likeasyncio_default_test_loop_scope
... is there something neat I've missed?The text was updated successfully, but these errors were encountered: