From c24c7e75e26516e032c750d49cec2b840fb128cf Mon Sep 17 00:00:00 2001 From: Tyler Richard Date: Tue, 26 Dec 2017 10:25:25 -0800 Subject: [PATCH] Added regression test for capfd in a fixture --- testing/test_capture.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/testing/test_capture.py b/testing/test_capture.py index 782971af0..da0fb5369 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1318,6 +1318,26 @@ def test_error_attribute_issue555(testdir): reprec = testdir.inline_run() reprec.assertoutcome(passed=1) +def test_capfd_after_test(testdir): + testdir.makepyfile(""" + import sys + import pytest + import os + + @pytest.fixture() + def fix(capfd): + yield + out, err = capfd.readouterr() + assert out == 'lolcatz' + os.linesep + assert err == 'err' + + def test_a(fix): + print("lolcatz") + sys.stderr.write("err") + """) + reprec = testdir.inline_run() + reprec.assertoutcome(passed=1) + @pytest.mark.skipif( not sys.platform.startswith("win") and sys.version_info[:2] >= (3, 6),