Repository navigation
Flush the real streams before each B0.2 test captures output - #596
Merged
Merged
Conversation
pytest-split writes its header to sys.stdout through the terminal writer and doesn't flush it when stdout is a pipe, as it is in CI. The B0.2 script's _flush_streams flushes sys.__stdout__, so the first test in a shard that runs it under capfd captured the header and failed its empty-output assertion. That test is test_a_failure_from_outside_this_script_prints_no_value. An autouse fixture now flushes sys.__stdout__ and sys.__stderr__ before each test in the module, so no earlier writer's text reaches a test's capture. The fixture adds no tests, so the tier files don't change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
The Microcosm Dynamics coordinator merged this PR at
|
MaxGhenis
added a commit
that referenced
this pull request
Nov 2, 2026
Master brings the B0.2 stream flush (#596), which touches one B0.2 test file and no Track B payment file. The tier files take master's counts plus this branch's new tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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.
What fails
On #574, one Tests shard fails at
tests/test_track_b_b0_2_counts.py::test_a_failure_from_outside_this_script_prints_no_value.The test asserts that
capfdholds("", "")afterscript.mainstops, andit finds pytest-split's header instead:
Why
self.writer.line(...), aterminal writer over
sys.stdout(pytest_split/plugin.py:124and:171–179). When stdout is a pipe, as in CI, that text waits unflushed in thebuffer of
sys.__stdout__._flush_streams(scripts/track_b_b0_2_counts.py:2340)flushes
sys.__stdout__andsys.__stderr__before_silencedredirectsfds 1 and 2.
-q, as CI runs pytest, nothing flushes that buffer before the firsttest's call report (
_pytest/terminal.py:699). At default verbosity thetest passes at master with pytest-split.
header into fd 1 while
capfdholds it, and the test captures text it neverwrote. In Aggregate-table captures and readers, part 1 (D4) #574's run (job 125184609985) it ran first in shard 3 of 4: that
shard's progress line opens with
F. Which test runs first depends on theshard split, so another change to the test set can move this one back to the
head of a group.
Fix
An autouse fixture in the module flushes
sys.__stdout__andsys.__stderr__before each test starts capturing. The script and its assertions don't change.
The fixture adds no tests, so the tier files don't change.
Checks run
master's test file with the header diff above, and passes with the fixture.
sys.stdoutat collection without flushingfails the test at master and passes with the fixture.
taskpolicy -b. The one failure,test_the_host_reads_see_a_background_policy_and_a_qos_clamp[policy1-qos], comes from that wrapper: it fails the same way at master undertaskpolicy -b, and it passes at both master and this branch in a plain run.Review
An independent Claude Opus 5.5 review returned APPROVE. It reproduced the
failure and the fix under real pytest-split, found the same latent failure in
test_relabeling_a_death_and_a_move_changes_no_written_byte[ages1-before1-0-7-released]when that test runs first, and showed that the fixture runs before
capfdstarts: moved after it, the target fails again. Five injected leaks from the
script still fail the target with the fixture in place. This PR's own shard
split doesn't put the target first, so its CI doesn't exercise the fix;
#574 does once it merges this.
🤖 Generated with Claude Code