fix issue547 2.6 regression: capsys/capfd now work again when output capturing ("-s") is disabled.
This commit is contained in:
parent
ba878c6d9d
commit
1265612465
|
@ -1,6 +1,8 @@
|
|||
NEXT
|
||||
-----------------------------------
|
||||
|
||||
- fix issue547 capsys/capfd also work when output capturing ("-s") is disabled.
|
||||
|
||||
- address issue170: allow pytest.mark.xfail(...) to specify expected exceptions via
|
||||
an optional "raises=EXC" argument where EXC can be a single exception
|
||||
or a tuple of exception classes. Thanks David Mohr for the complete
|
||||
|
|
|
@ -20,7 +20,7 @@ patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'}
|
|||
def pytest_addoption(parser):
|
||||
group = parser.getgroup("general")
|
||||
group._addoption(
|
||||
'--capture', action="store",
|
||||
'--capture', action="store",
|
||||
default="fd" if hasattr(os, "dup") else "sys",
|
||||
metavar="method", choices=['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__):
|
||||
ns = early_config.known_args_namespace
|
||||
pluginmanager = early_config.pluginmanager
|
||||
if ns.capture == "no":
|
||||
return
|
||||
capman = CaptureManager(ns.capture)
|
||||
pluginmanager.register(capman, "capturemanager")
|
||||
|
||||
|
|
|
@ -392,13 +392,14 @@ class TestLoggingInteraction:
|
|||
|
||||
|
||||
class TestCaptureFixture:
|
||||
def test_std_functional(self, testdir):
|
||||
@pytest.mark.parametrize("opt", [[], ["-s"]])
|
||||
def test_std_functional(self, testdir, opt):
|
||||
reprec = testdir.inline_runsource("""
|
||||
def test_hello(capsys):
|
||||
print (42)
|
||||
out, err = capsys.readouterr()
|
||||
assert out.startswith("42")
|
||||
""")
|
||||
""", *opt)
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
||||
def test_capsyscapfd(self, testdir):
|
||||
|
|
Loading…
Reference in New Issue