Added regression test for capfd in a fixture
This commit is contained in:
parent
273670b2a2
commit
c24c7e75e2
|
@ -1318,6 +1318,26 @@ def test_error_attribute_issue555(testdir):
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=1)
|
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(
|
@pytest.mark.skipif(
|
||||||
not sys.platform.startswith("win") and sys.version_info[:2] >= (3, 6),
|
not sys.platform.startswith("win") and sys.version_info[:2] >= (3, 6),
|
||||||
|
|
Loading…
Reference in New Issue