reset capture even if readouterr throws

otherwise that exception (and all following output) end up in /dev/null
This commit is contained in:
David Szotten
2015-07-26 01:15:51 +02:00
parent df29120abe
commit 983d249680
2 changed files with 22 additions and 2 deletions

View File

@@ -566,6 +566,24 @@ def test_capture_binary_output(testdir):
result.assert_outcomes(passed=2)
def test_error_during_readouterr(testdir):
"""Make sure we suspend capturing if errors occurr during readouterr"""
testdir.makepyfile(pytest_xyz="""
from _pytest.capture import FDCapture
def bad_snap(self):
raise Exception('boom')
FDCapture.snap = bad_snap
""")
result = testdir.runpytest_subprocess(
"-p", "pytest_xyz", "--version", syspathinsert=True
)
result.stderr.fnmatch_lines([
"*in bad_snap",
" raise Exception('boom')",
"Exception: boom",
])
class TestTextIO:
def test_text(self):
f = capture.TextIO()