fix: __init__.py (root) cannot be imported, breaks the entire test suite on pytest v.8.0.0+ - #91
Open
leopozh wants to merge 1 commit into
Open
fix: __init__.py (root) cannot be imported, breaks the entire test suite on pytest v.8.0.0+#91leopozh wants to merge 1 commit into
leopozh wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Anything pytest version 8.0.0 and later is erroring, when I first cloned into this repo the dev spec of pytest>=7.0.0 automatically set me at pytest 9.1.1
The
__init__.pyin root cannot get imported and the pytest tries to before going through every single test. The entire test suite errors when the repo is cloned by someone new.Issue was here, this is a relative import
When the
__init__.pyis present at the rootdir, pytest treats the root of the repo as a package and collects it as a Package node, and then Package.setup() imports the__init__.pyonce per test item.This causes every single test to error during the setup, removing this leads to all of them passing because there's nothing wrong with them.
This issue is NOT visible in pytest 7, but this change doesn't break that behavior. Tested it on pytest version 7.4.4 has 28 passed with and without the
__init__.pyfile (this is due to the test modules inserting the repo root onto sys.path, so the reliance on rootdir isn't present).Nothing in the repo imports it. The only relative imports at the root level are itself (lines 9-10).
The sub-package init files under core/ utils/ and evaluations/eval_datasets/ sit inside different packages, so their relative imports arent affected.