Repository navigation
fix: report a test module that fails to import - #226
Conversation
With --import-mode=importlib, the collection hook imported every test module and swallowed a failure. The half-run module stayed in sys.modules, so pytest's own import returned it with no tests and no error. The hook now imports only a module whose source declares ovoscope_intent_cases, and drops a module that fails to import so the real import reports it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reporting for duty! The automated checks have completed. 🎖️I've aggregated the results of the automated checks for this PR below. 📋 Repo HealthEvaluating the longevity of the project. 🌳 ✅ All required files present. Latest Version: ✅ 🔒 Security (pip-audit)I've checked the vulnerability database for hits. 🎯 ✅ No known vulnerabilities found (134 packages scanned). 🔍 LintJust a little bit of automation magic for you. ✨ ❌ ruff: issues found in 74 file(s) — see job log 🏷️ Release PreviewCrystal ball analysis: predicting the next version! 🔮 Current:
✅ PR title follows conventional commit format. 🚀 Release Channel Compatibility Predicted next version:
⚖️ License CheckScanning for any non-commercial-only restrictions. 💰 ✅ No license violations found. Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed. 📊 CoverageEnsuring the logic is battle-tested. ⚔️ Files below 80% coverage (16 files)
Full report: download the 🔨 Build TestsEnsuring the scaffolding is removed and the build is clean. 🧹 ✅ All versions pass
An automated hug for your code 🤗 |
What changes
A test module that fails to import is reported as a collection error again. Before this fix, a repo that runs pytest with
--import-mode=importliband has ovoscope installed collected such a module as zero tests with no error, so CI stayed green.Cause: the
pytest_pycollect_makemodulewrapper imports every test module, to look forovoscope_intent_cases, and swallows any failure. In importlib mode the half-run module stays insys.modules. pytest's own import then returns it. It has none of the tests defined after the failing line, and pytest has no error to show.Fix:
ovoscope_intent_cases. Other test modules are not imported early.sys.modules, so pytest's import raises and reports the error.Evidence
--import-mode=importlibModuleNotFoundError--import-mode=prependovoscope_intent_casesimportorskip(existing test)The new tests run pytest through
pytester. Both importlib cases failed ondevbefore the fix.Found in
ovos-m2v-pipeline, which sets--import-mode=importlib. A new test module with a missing import collected 0 tests and reported no error. Its suite collects 1099 tests both with and without the ovoscope plugin, so no broken module hides there today. Other repos with the same setup were not checked.🤖 Generated with Claude Code