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
Hello,
We've been stuck with version 0.21 for a while and now got some time to move on and update to latest version.
I think we've got it working but not quite understand the concept of the changes behind it. What's the changes in the event-loop mechanism before and after version 0.21
from pytest_asyncio import is_async_test
def pytest_collection_modifyitems(items):
pytest_asyncio_tests = (item for item in items if is_async_test(item))
session_scope_marker = pytest.mark.asyncio(loop_scope="session")
for async_test in pytest_asyncio_tests:
async_test.add_marker(session_scope_marker, append=False)
I understand that these set the the event loop for the test and the fixture to the same "session" loop.
I did some readings and discussion,
but I still don't understand exactly what's the changes that broke it and requires this setting. The changes doesn't seem to be explicitly documented anywhere, it may be embedded in discussions that I might have missed.
I can see documents describing a migration path, but not explain the mechanics of the changes behind the scene.
Without pytest_collection_modifyitems .. I do some experiment and it shows me that background tasks that I launch in the setup of the fixture doesn't run when the test function itself starts.
Without pytest_collection_modifyitems or (@pytest.mark.asyncio(loop_scope="session")) --> the background_task doesn't run when it enters the test_queue_writing
Could you please point me back to the basic of pytest-asyncio?
Thank you very much!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
We've been stuck with version 0.21 for a while and now got some time to move on and update to latest version.
I think we've got it working but not quite understand the concept of the changes behind it. What's the changes in the event-loop mechanism before and after version 0.21
Before:
After:
And
I understand that these set the the event loop for the test and the fixture to the same "session" loop.
I did some readings and discussion,
but I still don't understand exactly what's the changes that broke it and requires this setting. The changes doesn't seem to be explicitly documented anywhere, it may be embedded in discussions that I might have missed.
I can see documents describing a migration path, but not explain the mechanics of the changes behind the scene.
Without
pytest_collection_modifyitems
.. I do some experiment and it shows me that background tasks that I launch in the setup of the fixture doesn't run when the test function itself starts.For example i have this file
Without
pytest_collection_modifyitems
or (@pytest.mark.asyncio(loop_scope="session")) --> the background_task doesn't run when it enters thetest_queue_writing
Could you please point me back to the basic of pytest-asyncio?
Thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions