Skip to content

fix(tests): coverage report NoSource failure on main#1270

Merged
ocervell merged 1 commit into
mainfrom
fix/coverage-report-nosource-tempdir
Jul 3, 2026
Merged

fix(tests): coverage report NoSource failure on main#1270
ocervell merged 1 commit into
mainfrom
fix/coverage-report-nosource-tempdir

Conversation

@ocervell

@ocervell ocervell commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Problem

The Tests workflow is red on main — the coverage job fails at Run coverage report (coverage combine --keep succeeds, then coverage report -m prints no table and exits 1). Introduced by #1267.

Root cause (reproduced locally):

No source for code: '/tmp/tmp8dwgpdlo/mydriver.py'; see .../messages.html#error-no-source
EXIT=1

#1267's tests/unit/test_runner_hooks.py dropped the fake driver into a system TemporaryDirectory and imported it as secator.hooks.mydriver. Coverage recorded that /tmp/... path. The unit job passed (it only writes coverage data), but the separate coverage job combines the unit+integration data and runs coverage report; by then the tempdir is gone, so coverage raises NoSource and exits 1. The path isn't caught by --omit=*/site-packages/*,*/tests/*,*/templates/*.

Fix

Mirror the existing tests/unit/test_loader.py convention: write the driver into the real CONFIG.dirs.templates dir (its path contains /templates/, so the report's --omit=*/templates/* excludes it) and clean it up in tearDownClass. 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; then coverage report --omit=…exit 0, full table, 0 "No source" errors (was exit 1 before).
  • Driver file is removed after the run (no stray file left in ~/.secator/templates/).
  • flake8 clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated hook-related test coverage to use a real external driver fixture during initialization.
    • Improved validation for custom hook registration, persistence after serialization, and repeated context application.

…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
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Test 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.

Changes

Runner Hooks Test Fixture Migration

Layer / File(s) Summary
Fixture setup/teardown and test references
tests/unit/test_runner_hooks.py
Custom driver is now written to custom_hook_driver.py under the real templates directory, with discovery cache cleared/reset in setUpClass and file/module cleanup in tearDownClass; tests updated to reference custom_hook_driver instead of mydriver.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit hopped through templates true,
Swapped out "mydriver" for something new,
No tempdir tricks, just the real place,
Hooks still fire with steady grace. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing a test-related coverage report NoSource failure on main.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/coverage-report-nosource-tempdir

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ocervell ocervell changed the title test(runner-hooks): fix coverage report NoSource failure on main fix(tests): fix coverage report NoSource failure on main Jul 3, 2026
@ocervell ocervell changed the title fix(tests): fix coverage report NoSource failure on main fix(tests): coverage report NoSource failure on main Jul 3, 2026
@ocervell ocervell merged commit 8b3a2a3 into main Jul 3, 2026
8 of 9 checks passed
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant