-
Notifications
You must be signed in to change notification settings - Fork 152
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
Strange behaviour with asyncio.create_task and fixture scope #904
Comments
I see two issues here:
Let me know if this helps. |
|
Thanks for reporting back! The multiple event loops thing may not be immediately obvious. Do you have any suggestions what could be improved in the usage of pytest-asyncio or in docs to make this more understandable? |
Hmm.. After reading the docs carefully again it is quiet clearly stated there (my bad I guess) |
I agree with the warning! #873 is aimed at notifying the user in more cases when the scopes don't match |
In the following script I create a asyncio task in a fixture which should read the contents of a given queue in the background the moment something gets put into the queue. When the @fixture(scope="function", autouse=True) all the values get read from the queue as they are written to it (as expected). When I change the fixture to @fixture(scope="module", autouse=True) the values only get read from the queue at teardown - the task gets continued only while teardown. In fact this behavior appears for every scope!="function". This seems to be the case for every task created in a fixture and leads to not working tests for fixtures with scopes other than "function".
Am I missing something here and this is intended behavior? Or is this a bug?
(scope="function") Expected behavior. The messages get read while the test is running - The task gets continued while the test is running
(scope="module") Unexpected behavior. The messages get read at teardown - The task gets continued after the test is run
The text was updated successfully, but these errors were encountered: