Repository navigation
test(cli): tests assert outcome and raises match error - #2864
Merged
Merged
Conversation
Each test asserts the outcome that its name states. Each pytest.raises call of a built-in exception passes match or checks the exit code. Configures Ruff PT011 to require match for built-in exceptions. Adds an ast-grep rule to fail test functions without assertions. Closes #2171
Registers test-function-has-assertion in invariant and construct test tables.
dan-petty
force-pushed
the
test/2171-tests-assert-outcome-and-match-raises
branch
from
October 31, 2026 13:56
8b5aea3 to
e652b71
Compare
dan-petty
marked this pull request as ready for review
October 31, 2026 14:11
This was referenced Oct 31, 2026
Closed
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.
Description
This pull request ensures that tests check their stated outcomes and that exception checks are specific.
tests/commands/test_argo.py:test_valid_k8s_label_namesandtest_valid_k8s_resource_namesassert return values areNone.tests/http/test_http_connection_pool.py:test_closing_an_empty_registry_is_harmlessasserts the client registry is empty.tests/k8s/test_k8s_security_stream.py:test_render_security_alerts_emptyasserts empty alert output.tests/ai/test_output.py:test_print_panel_fallback_on_exceptionasserts fallback panel text.tests/ai/review/test_review_runner.py:test_rendering_helpersasserts rendered output.tests/commands/test_vault_cmd.py:test_validate_vault_path_validasserts valid path checks returnNone.tests/core/test_docker_engine.py:test_remove_container_tolerates_already_reapedalready asserts call names.tests/http/test_http.py:test_public_https_url_allowedandtest_public_http_url_allowedwere replaced by egress tests intests/http/test_http_egress.py.match=orexc.value.codechecks to built-in exceptionpytest.raisessites across the test suite.PT011(raises-require-match-for) inpyproject.tomlfor built-in exceptions.test-function-has-assertionast-grep rule and rule test to prevent test functions without assertions.Verification
uv run pytest.pytest.raisessites passmatch=or verifyexc.value.code.pytest.raises(KeyError)withoutmatch=.ast-grep scanfails on a scratch test function without assertions, andast-grep testpasses.test_valid_k8s_label_names,test_validate_vault_path_valid,test_entry_main_version).Closes #2171