Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2736,7 +2736,7 @@ def advance(seconds):


@pytest.mark.parametrize("after", ["pending", "late_success", "head_move", "blocker", "cancelled"])
def test_ready_transition_preserves_deadline_and_gates(wt, gh, capsys, monkeypatch, head, after):
def test_ready_transition_preserves_deadline_and_gates(wt, gh, capsys, monkeypatch, head, after, replay_gh):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Opt-in style is inconsistent with neighbouring replay tests

Neighbouring tests at test_cli.py:2688 and :2784 opt in with @pytest.mark.usefixtures("replay_gh"). This diff instead adds replay_gh as an unused parameter in three test_cli tests (2739, 2820, 2867). That pushes lines 2739 and 2820 past the 100-character line-length, and at 2867 it puts head, replay_gh, on one line, breaking the one-parameter-per-line layout. Nothing fails because ruff does not select E501 and tests ignore ARG, but the file now has two ways to do the same thing. Smallest fix: use @pytest.mark.usefixtures("replay_gh") on these three tests to match the existing ones. In test_review_recovery.py, the two tests where replay_gh is the last parameter can switch the same way. Keep test_historical_publication_recovery_is_exact_and_legacy_only as it is (see the next finding).

arm_approved_pr_with_check_result(gh, head, wt, "pending")
gh.respond("pr ready", "")
clock, sleeps, transitioned = [0.0], [], [False]
Expand Down Expand Up @@ -2817,14 +2817,13 @@ def advance(seconds):


@pytest.mark.parametrize("wait,draft", [(True, True), (False, True), (True, False)])
def test_ready_transition_immediate_green_is_best_effort(wt, gh, capsys, head, wait, draft):
def test_ready_transition_immediate_green_is_best_effort(wt, gh, capsys, head, wait, draft, replay_gh):
arm_approved_ready_pr(gh, head, wt, isDraft=draft)
gh.respond("pr ready", "")

code, out, err = run(capsys, "ready", *(["--wait"] if wait else []))

out = without_accepted_receipt(out)
assert (code, out, err) == (0, f"ready: {URL}\n", "")
assert (code, without_accepted_receipt(out), err) == (0, f"ready: {URL}\n", "")
assert sum(c["argv"][:2] == ["pr", "ready"] for c in gh.calls) == int(draft)
observations = sum(c["argv"][:2] == ["api", f"repos/{REPO}/commits/{head}/check-runs"]
for c in gh.calls)
Expand Down Expand Up @@ -2865,7 +2864,7 @@ def test_ready_wait_review_failure_freshness(
wait,
expected,
waited,
head,
head, replay_gh,
) -> None:
(wt / "workflow.toml").write_text(WORKFLOW.replace('["checks"]', json.dumps([name])))
arm_approved_pr_with_check_result(
Expand Down
7 changes: 4 additions & 3 deletions tests/test_review_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)

gh, git_seed, repo, wt = support.gh, support.git_seed, support.repo, support.wt
replay_gh = support.replay_gh
REVIEW_COMMENTS = f"api repos/{REPO}/pulls/7/reviews/17/comments?per_page=100&page=1"


Expand Down Expand Up @@ -88,7 +89,7 @@ def assert_single_publication(gh, fake_bin):
@pytest.mark.parametrize("verdict", [0, 5])
@pytest.mark.parametrize("interrupted", [False, True, "timeout"])
def test_accepted_publication_recovers_saved_verdict(
wt, gh, fake_bin, monkeypatch, capsys, kind, verdict, interrupted,
wt, gh, fake_bin, monkeypatch, capsys, kind, verdict, interrupted, replay_gh,
):
lost_reply(wt, gh, fake_bin, monkeypatch, kind=kind, verdict=verdict,
interrupted=interrupted is True, timeout=interrupted == "timeout")
Expand All @@ -113,7 +114,7 @@ def test_accepted_publication_recovers_saved_verdict(
"head", "comment_page", "kind", "wrong_head"])
@pytest.mark.parametrize("interrupted", [False, True])
def test_recovery_requires_exact_live_publication(
wt, gh, fake_bin, monkeypatch, capsys, change, interrupted,
wt, gh, fake_bin, monkeypatch, capsys, change, interrupted, replay_gh,
):
def mutate(rows, comments):
if change == "body":
Expand Down Expand Up @@ -247,7 +248,7 @@ def request(argv, **kwargs):
("null", "single"), ("empty", "single"), ("malformed", "single"),
])
def test_historical_publication_recovery_is_exact_and_legacy_only(
interrupted_receipt, gh, fake_bin, capsys, metadata, source, shape,
replay_gh, interrupted_receipt, gh, fake_bin, capsys, metadata, source, shape,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Replay coverage of the interrupted_receipt setup depends on parameter order

In this test replay_gh has to come before interrupted_receipt. Pytest builds fixtures in parameter order, and interrupted_receipt runs a full review while it is being set up. Because replay_gh comes first, repo's local_transport wraps the replay runner and that setup review is replayed in-process. If someone reorders the parameters, the setup review quietly goes back to the fake gh subprocess and the tests still pass. Smallest fix: make the dependency explicit, either by having interrupted_receipt request replay_gh itself or by adding a short comment explaining why the order matters.

):
head, path, saved, _ = interrupted_receipt
envelope = json.loads(saved["raw"])
Expand Down
Loading