-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
pytest example in testing.rst #939
Comments
In addition the examples refer to a |
When I try to naively update the example to use |
Agree that there is a confusion with the Talking about the issue that you mentioned it is a well known issue that is like a pain in the ass, and already reported and in the roadmap for future versions of There is a workaround that can be modified and use it to avoid the issue of close the loop just after the execution of the tests. The following fixture will replace the @pytest.yield_fixture
def loop():
with loop_context() as loop:
yield loop
@pytest.yield_fixture
def event_loop(loop):
loop._close = loop.close
loop.close = lambda: None
yield loop
loop.close = loop._close However will be nice if the guys from asyncio keep on eye on the pytest-asyncio project and once this issue will be fixed code another test example using the pattern that uses |
Yes, the test code isn't oriented to pytest-asyncio but it mentions you assume you use it in a comment, which is very misleading, as it's the opposite of what it actually does... I went with ignoring pytest-asyncio altogether myself. The documentation should be modified so it says you shouldn't be using pytest-asyncio if you use this pattern. |
I think the issue can be closed. Feel free to open another one if you discovered a new issue with testing doc. |
There are a few confusing things concerning pytest in
testing.rst
:@asyncio.coroutine
andyield from
.# assuming you are using pytest-asyncio
" but then it sets up its entirely independentloop
fixture and usesloop.run_until_complete
explicitly, instead of usingpytest.mark.asyncio
frompytest-asyncio
If people agree that these should be changed to async/await and
pytest.mark.asyncio
then I can create a pull request to update the example.The text was updated successfully, but these errors were encountered: