diff --git a/testing/test_capture.py b/testing/test_capture.py index 3c4398f61..0d1824ad8 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1010,3 +1010,21 @@ def test_capturing_and_logging_fundamentals(testdir, method): WARNING:root:hello2 """) assert "atexit" not in result.stderr.str() + +def test_close_and_capture_again(testdir): + testdir.makepyfile(""" + import os + def test_close(): + os.close(1) + def test_capture_again(): + os.write(1, "hello\\n") + assert 0 + """) + result = testdir.runpytest() + result.stdout.fnmatch_lines(""" + *test_capture_again* + *assert 0* + *stdout* + *hello* + """) +