From 68e58e1493e2e5f9e9fb78c2ccf9e05df8432eb7 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 2 Apr 2014 20:29:10 +0200 Subject: [PATCH] add a test for robustness of capturing when a test closes FD1/2 --- testing/test_capture.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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* + """) +