Skip to content

Python 3.10 compatibility #214

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

Merged
merged 8 commits into from
May 30, 2021

Conversation

seifertm
Copy link
Contributor

Adjusted or reworked test suite to be compatible with Python 3.10.

Using asyncio.get_event_loop() with Python 3.10 results in a DeprecationWarning. Tests using the functionality were adjusted accordingly. Some test were slightly reworked based on the original test intentions of the respective authors. Please refer to the commit for the rationale behind the individual changes.

Closes #212

seifertm added 3 commits May 17, 2021 16:08
…alization as in the plugin.

The plugin code creates a new event loop from the current event loop policy, whereas the fixture in the Hypothesis test uses get_event_loop. In Python 3.10 the use of get_event_loop was deprecated and causes the Hypothesis tests to fail.

Signed-off-by: Michael Seifert <[email protected]>
…has no effect.

Under Python 3.10, the remove_loop fixture raises:
"DeprecationWarning: There is no current event loop"
This means that the remove_loop fixture effectively does nothing.

The test case is still kept, because it seemingly aims to test that the "asyncio" marker works inside test classes when no "event_loop" fixture is explicitly specified.

Signed-off-by: Michael Seifert <[email protected]>
…the asyncio marker in class-based tests.

Rephrased test names and comments to make the test intention more clear.

Signed-off-by: Michael Seifert <[email protected]>
@seifertm seifertm force-pushed the issue-212-python-3.10-compat branch from 08d6d77 to 8b8e5a9 Compare May 21, 2021 06:32
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2021

Codecov Report

Merging #214 (43685c8) into master (29a4265) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #214   +/-   ##
=======================================
  Coverage   95.86%   95.86%           
=======================================
  Files           2        2           
  Lines         145      145           
=======================================
  Hits          139      139           
  Misses          6        6           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29a4265...43685c8. Read the comment docs.

seifertm added 5 commits May 21, 2021 08:40
…osed.

Under Python 3.10, the tests raise:
"DeprecationWarning: There is no current event loop"
This means that the asyncio.get_event_loop does not return any existing loop. It creates a new loop as a side effect instead. Therefore, test_1 and test_3 will always be successful.

However, it would be wrong to simply delete the tests without a replacement. Although, we cannot retrieve the default loop with get_event_loop, we can still retrieve it from the event loop policy. The new tests do exactly that and assert that the loop is a different object than in the tests before.

Signed-off-by: Michael Seifert <[email protected]>
…ecationWarning on Python 3.10.

The code was adjusted to use asyncio.get_event_loop_policy().get_event_loop() rather than the deprecated asyncio.get_event_loop().
Some additional comments were added to clarify the circumstances under which the test can fail.

Signed-off-by: Michael Seifert <[email protected]>
Adjusted changelog and setup.py accordingly.

Signed-off-by: Michael Seifert <[email protected]>
@seifertm seifertm force-pushed the issue-212-python-3.10-compat branch from 8b8e5a9 to 43685c8 Compare May 21, 2021 06:41
@Tinche
Copy link
Member

Tinche commented May 30, 2021

Nice! This is very valuable work. Thank you.

@Tinche Tinche merged commit 6ec7647 into pytest-dev:master May 30, 2021
@seifertm seifertm deleted the issue-212-python-3.10-compat branch October 8, 2022 06:40
@seifertm seifertm restored the issue-212-python-3.10-compat branch October 8, 2022 09:01
@seifertm seifertm deleted the issue-212-python-3.10-compat branch October 8, 2022 09:02
@seifertm seifertm assigned seifertm and unassigned seifertm Dec 8, 2022
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.

Python 3.10: DeprecationWarning: There is no current event loop
3 participants