Skip to content
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

Deprecate closing of existing loops #510

Conversation

seifertm
Copy link
Contributor

asyncio.get_event_loop() will effectively become an alias to asyncio.get_running_loop() in future Python versions. [0] As a result, pytest-asyncio will no longer be able to retrieve the current loop and close it for the user.

This PR raises a deprecation warning when the event_loop fixture is torn down and the current loop is unclosed. This will hopefully nudge users towards correct event loop handling and prevent breakage of their tests when pytest-asyncio removes the use of get_event_loop().

I think the previous PR didn't go far enough with emitting a ResourceWarning, because ResourceWarnings are not displayed by default.

[0] Deprecate get_event_loop()

…et_event_loop.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
…cationWarning.

Changing the warning type emphasizes that the functionality will no longer be available in the future.

The commit also extends the tests for the deprecation warning and adjusts the changlog entry and deprecation message.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
@seifertm seifertm merged commit 947e31a into pytest-dev:master Mar 19, 2023
@seifertm seifertm deleted the feat/warn-when-test-starts-with-unclosed-loop branch October 23, 2023 06:15
@seifertm seifertm restored the feat/warn-when-test-starts-with-unclosed-loop branch October 23, 2023 08:17
@seifertm seifertm deleted the feat/warn-when-test-starts-with-unclosed-loop branch October 23, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant