def test_error_during_readouterr(testdir):
 testdir.makepyfile(pytest_xyz="\n        from _pytest.capture import FDCapture\n        def bad_snap(self):\n            raise Exception('boom')\n        assert FDCapture.snap\n        FDCapture.snap = bad_snap\n    ")
 result = testdir.runpytest_subprocess('-p', 'pytest_xyz', '--version', syspathinsert=True)
 result.stderr.fnmatch_lines(['*in bad_snap', "    raise Exception('boom')", 'Exception: boom'])

def test_error_during_readouterr ( testdir ) : testdir . makepyfile ( pytest_xyz = "\n        from _pytest.capture import FDCapture\n        def bad_snap(self):\n            raise Exception('boom')\n        assert FDCapture.snap\n        FDCapture.snap = bad_snap\n    " ) result = testdir . runpytest_subprocess ( '-p' , 'pytest_xyz' , '--version' , syspathinsert = True ) result . stderr . fnmatch_lines ( [ '*in bad_snap' , "    raise Exception('boom')" , 'Exception: boom' ] )
make sure we suspend capturing if errors occurr during readouterr .