Repository navigation
Consolidate repeated test setup and scenario assertions - #1795
Conversation
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on 46c1a57901226d79be06875dab1e3e4d82e4e953, 73.0s: approve (0 critical, 0 important, 2 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Native Claude output is retained in the restricted local review receipt.
| head = lost_reply(wt, gh, fake_bin, monkeypatch, kind="delta", verdict=5, interrupted=True) | ||
| assert run(capsys, "review")[0] == 130 | ||
| path = wt / ".loopzero" / f"review-{head[:12]}-delta.json" | ||
| path = cli._review_file(wt, head, "delta") |
There was a problem hiding this comment.
suggestion: Expected review-file path now comes from the production helper
The test used to spell out the expected path as wt / ".loopzero" / f"review-{head[:12]}-delta.json". It now calls cli._review_file(wt, head, "delta"), so the expected value comes from the same production code it is checking. If someone changes the on-disk naming by mistake, for example the prefix length or the kind suffix, this test will follow the change and still pass. This is the only line in the change that replaces a hard-coded expectation with production logic. Smallest fix: keep the literal path, which costs no extra lines.
| @pytest.mark.parametrize("failure", ["http503", "dropped_read", "truncated"]) | ||
| def test_api_get_retries_transient_reads(monkeypatch, failure): | ||
| calls = [] | ||
| @pytest.mark.parametrize("failure,expected_sleeps", [ |
There was a problem hiding this comment.
suggestion: Merged retry/terminal test branches on the parameter type
test_api_get_retries_and_classifies_failures now handles three different failure mechanisms in one test: an HTTP 503, a failing body read, and a URLError. The fake opener and the final assertions both branch on failure == "http503" or failure in body_errors. Coverage is the same or better, and it now also asserts sleeps == [2.0] on the transient paths. The cost is that the fake's behaviour is decided by the type of the parameter, and that is easy to break when adding a case. For example, a new string failure that is meant to be transient would silently become a terminal URLError. Consider a small explicit mode field in each parameter tuple instead of inferring the mode. test_provider_errors_are_typed in tests/test_runners.py has the same pattern: whether the case is malformed output is inferred from exit_code == 0, and the codex fake swaps stdout and stderr on that basis.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Consolidate repeated test setup and scenario assertions
Context and goal
Acceptance
Validation
Recorded for
46c1a5790122uv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0All six changed test files passed. The optional IntelFlo policy snapshot cases stayed skipped because no pinned snapshot was supplied.
Integrated size proof at main ec7a26f: tests 13,774 → 13,671 (−103, headroom 179). Source 8,145/8,250, core docs 1,500/1,500, delegation docs 596/660, and complexity passed.
Six isolated spot mutations each made a retained test fail, and the same test passed after restoring source. They covered candidate tree comparison, explicit GitHub GET pagination, producing workflow identity, Mergify retry delay, publication body verification, and Claude authentication environment forwarding. The proof used independent bytecode caches for each mutated and restored run.
The PR changes tests only. Architecture and production behavior are unchanged.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review