-
Notifications
You must be signed in to change notification settings - Fork 41
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
Return original event loop after test case #7
Comments
Thanks for reporting your issue. Can you explain me why you want or need the loop outside the test case? It seems like a legitimate request, but I want to be sure it's implemented correctly, because I don't want to introduce confusion about the state of the default loop in a test function. I am considering doing the following:
In any case, |
Thank you for a quick reply. I don't explicitly need the loop outside of the test case. But i have couple of old test cases which are using Then i start using Correct way would be mocking out asyncio parts from these objects, and i will do so. |
Yes, you are right about the state change. I will try to push a fix today. |
I close the bug, I will put a release on pypi soon. |
Description
After running any test case which is using async test, the loop will end up closed. Which is because:
asynctest.TestCase
initializing new test it creates new loop in_init_loop
method.Then this closed loop end up as current loop.
Issue
The problem is that, after running any async test case, the
asyncio
module end up in unusable and different state than which it was before running tests.Solution
_init_loop
store reference to original event loop, and then proceed same way._unset_loop
to set original loop backThe text was updated successfully, but these errors were encountered: