fix issue547 2.6 regression: capsys/capfd now work again when output capturing ("-s") is disabled.

This commit is contained in:
holger krekel 2014-07-28 13:17:37 +02:00
parent ba878c6d9d
commit 1265612465
3 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,8 @@
NEXT NEXT
----------------------------------- -----------------------------------
- fix issue547 capsys/capfd also work when output capturing ("-s") is disabled.
- address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via - address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via
an optional "raises=EXC" argument where EXC can be a single exception an optional "raises=EXC" argument where EXC can be a single exception
or a tuple of exception classes. Thanks David Mohr for the complete or a tuple of exception classes. Thanks David Mohr for the complete

View File

@ -20,7 +20,7 @@ patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'}
def pytest_addoption(parser): def pytest_addoption(parser):
group = parser.getgroup("general") group = parser.getgroup("general")
group._addoption( group._addoption(
'--capture', action="store", '--capture', action="store",
default="fd" if hasattr(os, "dup") else "sys", default="fd" if hasattr(os, "dup") else "sys",
metavar="method", choices=['fd', 'sys', 'no'], metavar="method", choices=['fd', 'sys', 'no'],
help="per-test capturing method: one of fd|sys|no.") help="per-test capturing method: one of fd|sys|no.")
@ -33,8 +33,6 @@ def pytest_addoption(parser):
def pytest_load_initial_conftests(early_config, parser, args, __multicall__): def pytest_load_initial_conftests(early_config, parser, args, __multicall__):
ns = early_config.known_args_namespace ns = early_config.known_args_namespace
pluginmanager = early_config.pluginmanager pluginmanager = early_config.pluginmanager
if ns.capture == "no":
return
capman = CaptureManager(ns.capture) capman = CaptureManager(ns.capture)
pluginmanager.register(capman, "capturemanager") pluginmanager.register(capman, "capturemanager")

View File

@ -392,13 +392,14 @@ class TestLoggingInteraction:
class TestCaptureFixture: class TestCaptureFixture:
def test_std_functional(self, testdir): @pytest.mark.parametrize("opt", [[], ["-s"]])
def test_std_functional(self, testdir, opt):
reprec = testdir.inline_runsource(""" reprec = testdir.inline_runsource("""
def test_hello(capsys): def test_hello(capsys):
print (42) print (42)
out, err = capsys.readouterr() out, err = capsys.readouterr()
assert out.startswith("42") assert out.startswith("42")
""") """, *opt)
reprec.assertoutcome(passed=1) reprec.assertoutcome(passed=1)
def test_capsyscapfd(self, testdir): def test_capsyscapfd(self, testdir):