Repository navigation
Description
What happened
Some tests do not check what they claim. The test-suite audit of 2026-10-24 at df8e2ee found two kinds:
Tests with no assertion (10). Each one passes as long as the code raises nothing:
tests/test_argo.py:34test_valid_k8s_label_namesand:66test_valid_k8s_resource_namestests/test_docker_engine.py:1116test_remove_container_tolerates_already_reapedtests/test_http.py:12test_public_https_url_allowedand:21test_public_http_url_allowedtests/test_http_connection_pool.py:177test_closing_an_empty_registry_is_harmlesstests/test_k8s_security_stream.py:234test_render_security_alerts_emptytests/test_output.py:756test_print_panel_fallback_on_exceptiontests/test_review_runner.py:51test_rendering_helpers(40 lines)tests/test_vault_cmd.py:95test_validate_vault_path_valid
pytest.raises(<built-in exception>) with no match= (39 sites). A built-in exception such as KeyError, AttributeError, RuntimeError or SystemExit can come from any line, so the test passes when the code fails for another reason. The sites are in tests/test_ai_client_providers_and_embeddings.py:525-535 (6), tests/test_fast_dispatch.py:97, :124, :131, :140, :177, tests/test_personas.py:32, :35, :43, tests/test_ai_agent_capabilities.py:229, :232, tests/test_github_rate_limiter.py:821, :1529, tests/test_config_commands.py:359, tests/test_roadmap_intake.py:1758, tests/test_validation.py:456, :501, :519, tests/test_http_egress.py:611, :613, tests/test_pydantic_ai_mcp.py:166, tests/test_process.py:85, :108, tests/test_isolation_tripwire.py:132, tests/test_docs.py:697, :726, tests/test_consolidation_dry_run_decorator.py:77, tests/test_memory_profiler.py:201, tests/test_rag_query_telemetry.py:365, tests/test_telemetry.py:423, tests/test_review_pipeline.py:153, tests/test_rag_embeddings.py:716 and tests/test_devcontainer.py:1994.
What should happen
- Each test asserts the outcome that its name states, as a whole value where it can (docs/TESTING.md, "Names and assertions").
- Each
pytest.raisesof a built-in exception passesmatch=with the message that only the expected failure gives, or checks the exit code of aSystemExit. - Checks stop new cases. Ruff's
PT011, withraises-require-match-forset to the built-in exceptions, flags apytest.raiseswith nomatch=, and thelintrow runs it. An ast-grep rule in.ast-grep/rules/, run by theconstructsrow, flags a test function with noassert, nopytest.raisesand no fake check.
Evidence
.data/agent/scratch/audit/full_list.txtof the 2026-10-24 audit, sections 4.no-assertion and 4.builtin-raises-without-match. Every line exists at b170358.pyproject.toml:124:PT011is selected, with the defaultraises-require-match-forlist.tests/test_architectural_invariants.py:1393already banspytest.raises(Exception).
Acceptance criteria
- Each of the 10 tests asserts its outcome, or it is deleted when another test already asserts it. The pull request names the other test.
- Each of the 39 sites passes
match=or checks the exit code. - A check in
devops cifails a new test with no assertion and a newpytest.raisesof a built-in exception with nomatch=. The pull request shows both failing on a scratch case. - Each changed test fails when the behaviour it checks is broken. The pull request shows this for three of them.
-
uv run devops cipasses.
The tests that check only mock calls (126 in the audit) are not in scope: each child of #1307 replaces those doubles with shared fakes and asserts whole values (#1307, Q7).
Proposed design
Problem statement
Ten tests pass without checking any outcome, and 39 pytest.raises sites catch a built-in exception without a match= or exit-code check. A test that raises nothing, or raises the wrong exception, still passes. The project needs each test to assert the value it claims, each built-in-exception raises to name the expected message, and two lint rules to stop new cases.
Acceptance criteria
- Criterion 1: Each of the 10 no-assertion tests asserts the outcome its name states, or is deleted with the covering test named in the pull request.
Verification: Runuv run pyteston each of the 10 named tests. Confirm each has anasserton a whole value, or is absent with the replacement test named in the PR description. - Criterion 2: Each of the 39 pytest.raises sites of a built-in exception passes match= with the expected message, or checks the SystemExit code.
Verification: Rungrep -rn 'pytest.raises' tests/ | grep -E 'KeyError|AttributeError|RuntimeError|SystemExit'and confirm every hit has amatch=argument or anexc.value.codecheck. - Criterion 3: Ruff PT011 with raises-require-match-for set to the built-in exceptions flags a new pytest.raises with no match=.
Verification: Add a scratch test withpytest.raises(KeyError)and nomatch=. Runuv run ruff check --select PT011on it. Confirm it fails. Delete the scratch test. - Criterion 4: An ast-grep rule in .ast-grep/rules/ flags a test function with no assert, no pytest.raises and no fake check.
Verification: Add a scratch test function with no assertion. Run the constructs row ofuv run devops ci. Confirm it fails. Delete the scratch test. - Criterion 5: Each changed test fails when the behaviour it checks is broken.
Verification: For three of the changed tests, temporarily break the behaviour they assert. Run the test. Confirm it fails. Restore the behaviour. - Criterion 6: The full CI suite passes after all changes.
Verification: Runuv run devops ci. Confirm it exits 0.
Key questions
- Which built-in exceptions go in the raises-require-match-for list?: KeyError, AttributeError, RuntimeError and SystemExit, as named in the issue body. (proposed)
- How is SystemExit handled differently from the other built-in exceptions?: A SystemExit site checks the exit code via exc.value.code instead of passing match=, because SystemExit carries an integer code, not a message string. (proposed)
- Where is PT011 currently configured?: PT011 is selected in pyproject.toml at line 126, with the default raises-require-match-for list. The change adds an explicit raises-require-match-for setting. [sources: pyproject.toml:126]
- Are the 126 mock-call-only tests in scope?: No. The body states they are out of scope. Each child of test(cli): tests double only process edges and mirror the source tree #1307 replaces those doubles with shared fakes and asserts whole values. (proposed)
Open questions
- Where do the ast-grep rules live and which CI row runs them? (missing verified source)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate focuses on improving test quality and assertions, which is a test type task.Tests without assertions or proper exception matching can lead to false positives in the test suite.Improving test assertions and exception handling increases confidence in test results and code quality.The candidate requires auditing and fixing a large number of tests, which is time-intensive.dan-petty commentedon Oct 27, 2026
Refine cannot set this item to Ready at 0abf552 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
test(cli): tests assert outcome and raises match error