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 errors during collection #728

Conversation

seifertm
Copy link
Contributor

There have been numerous bug reports related to a pytest INTERNALERROR triggered during test collection.The root cause is the installation of the scoped event loop fixture which triggers module imports during pytest_collectstart. This specific hook runs before the actual collection phase and is not equipped to deal with this kind of import errors.

This PR monkey patches each Module.collect call and prepends a statement that installs the scoped event loop as part of the collect call. This delays module imports until the collection phase where pytest deals with them properly.

Closes #713
Closes #719

…ortWarning in a module.

The fix monkey patches the pytest.Module.collect to attach the scoped event loop fixture to the module, rather than directly accessing Module.obj. This allows dropping all error handling related to module imports that has been added, because pytest_collectstart isn't meant to deal with those errors.

Signed-off-by: Michael Seifert <[email protected]>
@seifertm seifertm added this to the v0.23.3 milestone Dec 24, 2023
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (edb9ae0) 95.16% compared to head (7297584) 95.15%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #728      +/-   ##
==========================================
- Coverage   95.16%   95.15%   -0.02%     
==========================================
  Files           2        2              
  Lines         476      475       -1     
  Branches       94       94              
==========================================
- Hits          453      452       -1     
  Misses         16       16              
  Partials        7        7              

☔ 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 Jan 1, 2024
@seifertm seifertm modified the milestones: v0.23.3, v0.23 Jan 1, 2024
Merged via the queue into pytest-dev:main with commit 6a253e2 Jan 1, 2024
@seifertm seifertm deleted the adress-internal-pytest-errors-during-collection branch January 1, 2024 13:22
@seifertm seifertm restored the adress-internal-pytest-errors-during-collection branch January 7, 2024 15:47
@seifertm seifertm deleted the adress-internal-pytest-errors-during-collection branch January 9, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants