Merge reset-capgture-on-reeadouterr-errors
Merge branch 'reset-capture-on-readouterr-errors' of github.com:davidszotten/pytest into merge-capmerge
This commit is contained in:
commit
e68fa641ff
|
@ -86,7 +86,9 @@ class CaptureManager:
|
|||
self.deactivate_funcargs()
|
||||
cap = getattr(self, "_capturing", None)
|
||||
if cap is not None:
|
||||
try:
|
||||
outerr = cap.readouterr()
|
||||
finally:
|
||||
cap.suspend_capturing(in_=in_)
|
||||
return outerr
|
||||
|
||||
|
|
|
@ -566,6 +566,25 @@ 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')
|
||||
assert FDCapture.snap
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue