Skip to content
Merged
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
8 changes: 4 additions & 4 deletions tests/test_codex_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
fake_bwrap = test_runners.fake_bwrap
gh = test_cli.gh
APPROVE = test_runners.APPROVE
BYTE_LIMIT_REVIEW = test_runners._native_codex_result("a" * 40)

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: Shared result is built when the module is imported, and its provenance dict can be changed

BYTE_LIMIT_REVIEW is built when the module is collected, so every worker builds it even when these tests are deselected. If the build ever fails, the whole module fails to collect instead of just these 33 cases. The result is also shared across tests, and its provenance dict can be modified (runners.py:1354-1361 writes to provenance dicts during merges). The code paths these tests call today (codex_evidence, _review_body, review_projection, eligible_review) don't write to it, and parse_review is pure, so this is safe for now. For lazy creation and isolation, a module-scoped fixture (or functools.cache on a small factory) would give the same once-per-worker reuse.



@pytest.fixture
Expand Down Expand Up @@ -595,14 +596,13 @@ def test_entire_leading_block_budget_includes_adjudication(native, monkeypatch):
["\n", "\r\n", "\r", "\v", "\f", "\x1c", "\x1d", "\x1e", "\x85", "\u2028", "\u2029"],
)
@pytest.mark.parametrize("overflow", [0, 1, 2])
def test_raw_leading_utf8_span_at_limit_and_overflow(native, separator, overflow):
result = native[0]()
def test_raw_leading_utf8_span_at_limit_and_overflow(separator, overflow):
result = BYTE_LIMIT_REVIEW
marker = cli.review_marker(result.head, result.kind)
header = runners.encode_codex_evidence(runners.codex_evidence(result))
adjudication = "<!-- loopzero:adjudication v=1 replaces=1 target=" + result.head + " -->"
span = separator.join((marker, header, adjudication))
padding = 8192 + overflow - len(span.encode("utf-8"))
padded = marker[:-3] + " " * padding + marker[-3:]
padded = marker[:-3] + " " * (8192 + overflow - len(span.encode("utf-8"))) + marker[-3:]

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: Unrelated inlining of the padding computation makes the line harder to read

The old named padding variable is now folded into one long expression. This has no effect on speed or reuse, so it is unrelated to issue #1514 and only makes the byte arithmetic harder to check. Smallest fix: undo this hunk and keep padding = 8192 + overflow - len(span.encode("utf-8")).

span = separator.join((padded, header, adjudication))
assert len(span.encode("utf-8")) == 8192 + overflow
rendered = span + separator + "**approve**"
Expand Down
Loading