Repository navigation
Description
Problem
Three tests in tests/commands/test_scan.py fail on main in the devcontainer. Each one reaches a real tool without a fake:
test_scan_individual_toolsandtest_scan_serialized_output_holds_status_reason_and_findings[trivy]reach the host path~/.local/share/devops-cli/tools/trivy/0.75.0/trivy.test_scan_serialized_output_holds_status_reason_and_findings[sast]starts a realsemgrep scanprocess.
The edge guard of the test floor reports each one as "reached without a fake" and fails the test and its teardown (3 failures and 3 errors).
Steps to reproduce
- Use the devcontainer on current
main(commit 84117ac). - Run
uv run pytest tests/commands/test_scan.py -q.
Expected
The tests fake the scanners at their seam. They pass on any host, with or without trivy, gitleaks and semgrep installed (rule: every test works in the devcontainer and on the GitHub runner).
Notes
The fix is to fake each scanner at its edge (docs/TESTING.md), or to mark a real run @pytest.mark.live. Found while checking the full CI run of PR #4285; the failures are not part of that PR.
Proposed design
Problem statement
Three tests in tests/commands/test_scan.py reach a real trivy binary or a real semgrep process. The edge guard of the hermetic floor fails each one as "reached without a fake". The tests are test_scan_individual_tools and the trivy and sast cases of test_scan_serialized_output_holds_status_reason_and_findings. They must pass on any host, with or without the scanners installed.
Acceptance criteria
Requirement: Individual scan tools use the scanner fake
The test test_scan_individual_tools SHALL run trivy, secrets and sast through scanner_fake and SHALL start no real scanner program.
Scenario: Individual tools with the fake
- WHEN The test runs on a host with no trivy, gitleaks or semgrep installed
- THEN Each scan command exits 0 and the floor reports no unfaked edge
Requirement: Serialized output tests use the scanner fake
The test test_scan_serialized_output_holds_status_reason_and_findings SHALL give each of the trivy, secrets and sast cases a scripted answer from scanner_fake.
Scenario: JSON and YAML output with the fake
- WHEN The test invokes each scan subcommand with --json and with --format yaml
- THEN The output holds the status, reason and findings keys and the test passes with no real tool
Requirement: The scan test file passes on any host
The file tests/commands/test_scan.py SHALL pass in the devcontainer and on the GitHub runner, with or without the scanners installed.
Scenario: Whole file run
- WHEN uv run pytest tests/commands/test_scan.py -q runs on main with the fix
- THEN No test fails and no teardown error occurs
Existing Tool Considered
The need is covered by the project's own fake, ScannerFake in tests/support/fakes/scanners.py behind the scanner_fake fixture (docs/TESTING.md, ADR 0007). It already exists and test_scan_serialized_output_with_findings uses it. No new code or outside tool is needed. The cost is a small edit of one test file, with a few thousand tokens and under one hour.
Key questions
- Which seam fakes the scanners in these tests?: Use the scanner_fake fixture. docs/TESTING.md says a test whose code starts a scanner asks for scanner_fake, which answers the scanner request with a recorded run. The test test_scan_serialized_output_with_findings in the same file already does this for trivy. (best practice) [sources: docs/TESTING.md, tests/commands/test_scan.py]
- Chosen: scanner_fake with scripted ToolAnswer. It is the one fake of the scanner edge and it is the project rule.
- Rejected: Mark the tests
@pytest.mark.live. The tests check CLI output, not the real tools, and a live run would not pass on every host. - Rejected: Patch the scan functions of devops_cli. docs/TESTING.md bans a patch of a devops-cli name.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 9, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(scan)scope of the title gives the scope.Three tests fail on main in the devcontainer, blocking the local test suite, but no production behaviour is affected.Restores confidence in the scan test suite for developers using the devcontainer.Add a fake or a live marker to three existing tests; no new code path is needed.Both concern scan-area tests that need fakes, but #2543 moves security and crypto tests onto merged fakes while the candidate fixes three scan tests that reach real trivy and semgrep.devops-cli-service commentedon Nov 10, 2026
Status set to Ready at e99dc01 (see proposed design in issue body).
dan-petty commentedon Nov 11, 2026
This issue is a duplicate of #4321. Pull request #4440, which closes #4321, delivers it:
test_scan_individual_toolsand the three cases oftest_scan_serialized_output_holds_status_reason_and_findingsnow usescanner_fake. The filetests/commands/test_scan.pygives 25 passed with and without the scanners on PATH. I close this issue as not planned (duplicate).test(scan): fake the scanners in the scan command tests (#4440)