diff --git a/tests/test_track_b_b0_2_counts.py b/tests/test_track_b_b0_2_counts.py index f3d3da05..46e308de 100644 --- a/tests/test_track_b_b0_2_counts.py +++ b/tests/test_track_b_b0_2_counts.py @@ -53,6 +53,17 @@ ) +@pytest.fixture(autouse=True) +def _flush_the_real_streams(): + """Flush Python's original stdout and stderr before each test captures + anything. A plugin can leave text in them unflushed, as pytest-split + leaves its header when stdout is a pipe, and the script's own flush in + ``_flush_streams`` would then push that text into the test's ``capfd``.""" + for stream in (sys.__stdout__, sys.__stderr__): + if stream is not None: + stream.flush() + + def _row( person, wave=2011,