fix(ci): pytest 'import file mismatch' collection errors on test branch#993
Merged
Merged
Conversation
…collisions Duplicate test basenames (test_model.py, test_tool.py, test_session.py, test_trigger.py, test_api_key.py, test_rlm.py) exist in both tests/unit/v2 and tests/functional/v2 (and tests/functional/model). Without __init__.py files, pytest's default prepend import mode maps them to the same module name and aborts collection with 'import file mismatch'. --import-mode=importlib gives each file a fully-qualified module name, so unique basenames are no longer required.
Merged
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.
CI on the
testbranch (and any branch running the full suite) aborts collection with 6import file mismatcherrors:Root cause: duplicate test basenames (
test_model.py,test_tool.py,test_session.py,test_trigger.py,test_api_key.py,test_rlm.py) acrosstests/unit/v2,tests/functional/v2, andtests/functional/model. Most test dirs have no__init__.py, so pytest's default prepend import mode assigns both files the same top-level module name and aborts.Fix:
addopts = --import-mode=importlibinpytest.ini— each test file gets a fully-qualified module name, so unique basenames are no longer required. This is pytest's recommended mode for new projects.Verification:
pytest --collect-only: 1808 tests collected, 0 errors (was 1458 + 6 errors, collection interrupted)pytest tests/unit: 1388 passed, 4 skipped🤖 Generated with Claude Code
https://claude.ai/code/session_018dCb6BE5bqjCrmsiPDGLRr