From 0dd1c8bf14d25521d7a0af1bb637fa0699dca57f Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 11 Jul 2016 20:44:46 -0300 Subject: [PATCH] Add test to ensure capsys and capfd error out when using "getfixturevalue" inside a test --- testing/test_capture.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/testing/test_capture.py b/testing/test_capture.py index 2e69cfc85..c197c85e7 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -421,6 +421,25 @@ class TestCaptureFixture: "*capsys*capfd*same*time*", "*2 error*"]) + def test_capturing_getfixturevalue(self, testdir): + """Test that asking for "capfd" and "capsys" using request.getfixturevalue + in the same test is an error. + """ + testdir.makepyfile(""" + def test_one(capsys, request): + request.getfixturevalue("capfd") + def test_two(capfd, request): + request.getfixturevalue("capsys") + """) + result = testdir.runpytest() + result.stdout.fnmatch_lines([ + "*test_one*", + "*capsys*capfd*same*time*", + "*test_two*", + "*capsys*capfd*same*time*", + "*2 failed in*", + ]) + @pytest.mark.parametrize("method", ["sys", "fd"]) def test_capture_is_represented_on_failure_issue128(self, testdir, method): p = testdir.makepyfile("""