fix(tests): coverage report NoSource failure on main#1270
Merged
Conversation
…t doesn't fail PR #1267's test_runner_hooks.py dropped the fake driver into a system TemporaryDirectory and imported it as secator.hooks.mydriver. Coverage recorded that /tmp/... path; once the tempdir was gone, the separate `coverage` CI job (coverage combine + report) failed with "No source for code: '/tmp/.../mydriver.py'" and exited 1 (no table), turning main's Tests workflow red. Mirror the existing tests/unit/test_loader.py pattern: write the driver into the real CONFIG.dirs.templates dir (path contains '/templates/', so the report's --omit=*/templates/* excludes it) and clean it up in tearDownClass. No behavior change to the fix itself. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5vSjfkBuGAAHdKxHS3ySm
Contributor
WalkthroughTest fixtures in tests/unit/test_runner_hooks.py were updated to load a custom external driver from the real CONFIG.dirs.templates directory rather than a temporary directory. The driver was renamed from mydriver to custom_hook_driver across setup, teardown, and test assertions. ChangesRunner Hooks Test Fixture Migration
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
ocervell
added a commit
that referenced
this pull request
Jul 3, 2026
🤖 I have created a release *beep* *boop* --- ## [0.39.0](v0.38.0...v0.39.0) (2026-07-03) ### Features * **vulnerability:** add status field + carry-over across re-scans ([#1209](#1209)) ([0d7bf7d](0d7bf7d)) ### Bug Fixes * **cli:** missing "help" field in option raises ValueError ([#1230](#1230)) ([74a6b39](74a6b39)) * **config:** SECATOR_ADDONS_* invalid key override breaks Secator totally ([#1205](#1205)) ([2164993](2164993)) * dynamic task import order causing SyntaxError with external tasks ([#1213](#1213)) ([0e2fcd6](0e2fcd6)) * **exporters:** add runner warnings to report ([#1228](#1228)) ([1734f6b](1734f6b)) * **output:** display full node id instead of task name ([#1227](#1227)) ([e26f394](e26f394)) * **output:** Vulnerability colors display by severity, show tags for Tag ([#1229](#1229)) ([6ad35e3](6ad35e3)) * **runner:** remove __getstate__/__setstate__, load driver hooks at init ([#1267](#1267)) ([2c6d2e8](2c6d2e8)) * **tests:** coverage report NoSource failure on main ([#1270](#1270)) ([8b3a2a3](8b3a2a3)) ### Performance Improvements * **output-types:** cache keys() + O(1) deduplicate membership check ([#1220](#1220)) ([7a956e9](7a956e9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.
Problem
The
Testsworkflow is red on main — thecoveragejob fails at Run coverage report (coverage combine --keepsucceeds, thencoverage report -mprints no table and exits 1). Introduced by #1267.Root cause (reproduced locally):
#1267's
tests/unit/test_runner_hooks.pydropped the fake driver into a systemTemporaryDirectoryand imported it assecator.hooks.mydriver. Coverage recorded that/tmp/...path. The unit job passed (it only writes coverage data), but the separatecoveragejob combines the unit+integration data and runscoverage report; by then the tempdir is gone, so coverage raisesNoSourceand exits 1. The path isn't caught by--omit=*/site-packages/*,*/tests/*,*/templates/*.Fix
Mirror the existing
tests/unit/test_loader.pyconvention: write the driver into the realCONFIG.dirs.templatesdir (its path contains/templates/, so the report's--omit=*/templates/*excludes it) and clean it up intearDownClass. No change to the runtime fix from #1267 — this only relocates where the test's throwaway driver file lives.Verification
coverage run … test_runner_hooks.py→ 4 passed; thencoverage report --omit=…→ exit 0, full table, 0 "No source" errors (was exit 1 before).~/.secator/templates/).flake8clean.🤖 Generated with Claude Code
Summary by CodeRabbit