Add discussion in testing guide of how to reduce chances of getting test collection errors #2872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using pytest, I've noticed that it's harder to diagnose test collection errors than test failures (most recently in #2869 & #2870). Test collection errors don't result in good tracebacks, at least with the pytest settings from
pyproject.toml
. Test collection errors also prevent pytest from running the full test suite by default, which means we often get incomplete information.In this PR, I'm planning to add some tips to the testing guide on how to avoid getting test collection errors. In particular, if a test file contains code that has a chance of failing, that code should be put into either a fixture or an actual test. Pretty much I want to avoid situations like...
I may also look into ways to improve the reporting of test collection errors.
Just wanted to start this PR now as a placeholder since it might take me a month or three to get to it.