Skip to content

Commit 8985ca2

Browse files
author
Ronak Bhalgami
committed
tests(capture): add capteesys regression when -s; remove standalone test, integrate into test_capture.py
1 parent d78c477 commit 8985ca2

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

testing/test_capteesys_issue.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

testing/test_capture.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,30 @@ def test_one(capteesys):
478478
result.stdout.fnmatch_lines(["sTdoUt", "sTdeRr"]) # no tee, just reported
479479
assert not result.stderr.lines
480480

481+
def test_capteesys_no_global_capture(self, pytester: Pytester) -> None:
482+
"""When global capture is disabled (-s), capteesys should not duplicate output.
483+
484+
It should pass output straight through (printed once) and capteesys.readouterr()
485+
should return empty strings since no per-test capture is active.
486+
"""
487+
p = pytester.makepyfile(
488+
"""\
489+
import sys
490+
491+
def test_one(capteesys):
492+
print("sTdoUt")
493+
print("sTdeRr", file=sys.stderr)
494+
out, err = capteesys.readouterr()
495+
assert out == ""
496+
assert err == ""
497+
"""
498+
)
499+
# Run with -s to disable global capture; ensure each line appears exactly once
500+
result = pytester.runpytest_subprocess(p, "-s", "--quiet", "--quiet")
501+
assert result.ret == ExitCode.OK
502+
assert result.stdout.str().count("sTdoUt") == 1
503+
assert result.stderr.str().count("sTdeRr") == 1
504+
481505
def test_capsyscapfd(self, pytester: Pytester) -> None:
482506
p = pytester.makepyfile(
483507
"""\

0 commit comments

Comments
 (0)