-
Notifications
You must be signed in to change notification settings - Fork 160
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
Emit ResourceWarning on event_loop teardown when loop is unclosed #492
Emit ResourceWarning on event_loop teardown when loop is unclosed #492
Conversation
…ution of other tests with a custom event loop. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…ardown Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
… fixture finalizer. The fixture finalizer is invoked once for each fixture, whereas the hook may be invoked multiple times for any specific fixture. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…hesis/test_base Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…t_base using pytester. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…ent event loop has not been closed. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
… closing the loop and a finalizer for providing a new loop. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
… a single fixture. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
… a single fixture. Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
Codecov ReportBase: 93.77% // Head: 93.95% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #492 +/- ##
==========================================
+ Coverage 93.77% 93.95% +0.17%
==========================================
Files 2 2
Lines 273 281 +8
Branches 55 55
==========================================
+ Hits 256 264 +8
Misses 11 11
Partials 6 6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Pytest-asyncio goes to great lengths to be convenient to use. Any kind of event loop mismanagement, such as closed loops when starting a test or finishing a test are handled for the user. This is great from a user experience point of view, but it leaves the user in the dark that something is wrong with their event loop handling.
As outlined in a previous comment, I think that pytest-asyncio should provide more feedback whenever pytest-asyncio takes care of those gotchas.
This PR causes the event_loop fixture to emit a ResourceWarning during teardown when the loop has not been closed. ResourceWarnings are ignored by default, but can be shown with pytest's
-W default
switch or turned into exceptions with-W error
.When
-W error
is set, pytest will include the name of the last test. This is easier for users to debug than waiting for CPython to emit the ResourceWarning when the event loop is freed.The change uncovered a couple of unwanted side-effects in the pytest-asyncio test suite.