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

Address internal pytest error during collection of doctests #685

Merged
merged 1 commit into from
Nov 26, 2023

Conversation

seifertm
Copy link
Contributor

This PR fixes a bug that caused internal pytest errors during test collection with doctests.

Pytest-asyncio attaches an event loop of a particular scope to each collector during pytest_collectstart. The implementation did not account for the fact that collectors may have specialized subclasses, such as DoctestModule. This caused a KeyError during a dictionary access, leading to an internal pytest error in the collection phase.

This patch changes the implementation of pytest_collectstart to account for subclasses of collectors.

Resolves #679

…ection with doctests.

Pytest-asyncio attaches an event loop of a particular scope to each collector during pytest_collectstart. The implementation did not account for the fact that collectors may have specialized subclasses, such as DoctestModule. This caused a KeyError during a dictionary access, leading to an internal pytest error in the collection phase.

This patch changes the implementation of pytest_collectstart to account for subclasses of collectors.

Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
@seifertm seifertm added this to the v0.23 milestone Nov 22, 2023
@codecov-commenter
Copy link

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (810c9d7) 94.75% compared to head (61c986b) 94.56%.
Report is 3 commits behind head on main.

Files Patch % Lines
pytest_asyncio/plugin.py 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #685      +/-   ##
==========================================
- Coverage   94.75%   94.56%   -0.20%     
==========================================
  Files           2        2              
  Lines         458      460       +2     
  Branches       93       93              
==========================================
+ Hits          434      435       +1     
- Misses         15       16       +1     
  Partials        9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seifertm seifertm added this pull request to the merge queue Nov 26, 2023
Merged via the queue into pytest-dev:main with commit 144277b Nov 26, 2023
9 checks passed
@seifertm seifertm deleted the doctest-collection branch November 26, 2023 08:19
@seifertm seifertm restored the doctest-collection branch November 26, 2023 12:44
@seifertm seifertm deleted the doctest-collection branch November 26, 2023 13:06
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.

0.23.0a1 version causing INTERNALERROR at startup
2 participants