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

Fix internal error caused by pytest.skip statements #702

Merged
merged 2 commits into from
Dec 3, 2023

Conversation

seifertm
Copy link
Contributor

@seifertm seifertm commented Dec 3, 2023

Accessing pytest's module Module.obj to attach a scoped event loop fixture triggers a module import executing module-level statements. A module-level pytest.skip statement raises the Skipped OutcomeException or a Collector.CollectError. These cases are handled correctly when they happen inside Collector.collect(), but the scoped event loop is attached in pytest_collectstart which runs before the actual collect call. This causes pytest.skip statements to trigger a pytest INTERNALERROR.

This PR catches the exceptions and aborts the attachment of the scoped event loop fixture to the module. Since all tests in the module are skipped, a missing module-scoped loop shouldn't be an issue, because there are no tests that can potentially request it.

This is essentially the same approach as in #656
Resolves #701

This prevents unrelated tests from aggregating in test_simple.py.

Signed-off-by: Michael Seifert <[email protected]>
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0b34e8e) 94.81% compared to head (1f8ea0f) 94.86%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #702      +/-   ##
==========================================
+ Coverage   94.81%   94.86%   +0.04%     
==========================================
  Files           2        2              
  Lines         463      467       +4     
  Branches       92       92              
==========================================
+ Hits          439      443       +4     
  Misses         16       16              
  Partials        8        8              

☔ 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 Dec 3, 2023
Merged via the queue into pytest-dev:main with commit a214c3e Dec 3, 2023
8 checks passed
@seifertm seifertm deleted the fix-pytest-skip branch December 3, 2023 19:22
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.

Startup failure on Windows with Version 0.23.0
2 participants