Include new --capture-mode=tee-sys option

Fix #4597
This commit is contained in:
cmachalo
2019-12-03 14:15:13 -08:00
committed by Bruno Oliveira
parent 30f2729684
commit e13ad22364
7 changed files with 111 additions and 8 deletions
+25
View File
@@ -1285,3 +1285,28 @@ def test_pdb_can_be_rewritten(testdir):
]
)
assert result.ret == 1
def test_tee_stdio_captures_and_live_prints(testdir):
testpath = testdir.makepyfile(
"""
import sys
def test_simple():
print ("@this is stdout@")
print ("@this is stderr@", file=sys.stderr)
"""
)
result = testdir.runpytest_subprocess(
testpath, "--capture=tee-sys", "--junitxml=output.xml"
)
# ensure stdout/stderr were 'live printed'
result.stdout.fnmatch_lines(["*@this is stdout@*"])
result.stderr.fnmatch_lines(["*@this is stderr@*"])
# now ensure the output is in the junitxml
with open(os.path.join(testdir.tmpdir.strpath, "output.xml"), "r") as f:
fullXml = f.read()
assert "<system-out>@this is stdout@\n</system-out>" in fullXml
assert "<system-err>@this is stderr@\n</system-err>" in fullXml