don't manipulate FDs at all if output capturing is turned off.

This commit is contained in:
holger krekel 2013-09-27 09:49:39 +02:00
parent 3ab9b48782
commit 030c337c68
2 changed files with 11 additions and 3 deletions

View File

@ -34,9 +34,10 @@ def pytest_addoption(parser):
def pytest_configure(config):
config.option.verbose -= config.option.quiet
# we try hard to make printing resilient against
# later changes on FD level.
# later changes on FD level. (unless capturing is turned off)
stdout = py.std.sys.stdout
if hasattr(os, 'dup') and hasattr(stdout, 'fileno'):
capture = config.option.capture != "no"
if capture and hasattr(os, 'dup') and hasattr(stdout, 'fileno'):
try:
newstdout = py.io.dupfile(stdout, buffering=1,
encoding=stdout.encoding)

View File

@ -677,6 +677,13 @@ def test_fdopen_kept_alive_issue124(testdir):
"*2 passed*"
])
def test_nofd_manipulation_with_capture_disabled(testdir):
from _pytest.terminal import pytest_configure
config = testdir.parseconfig("--capture=no")
stdout = sys.stdout
pytest_configure(config)
reporter = config.pluginmanager.getplugin('terminalreporter')
assert reporter._tw._file == stdout
def test_tbstyle_native_setup_error(testdir):
p = testdir.makepyfile("""
@ -684,7 +691,7 @@ def test_tbstyle_native_setup_error(testdir):
@pytest.fixture
def setup_error_fixture():
raise Exception("error in exception")
def test_error_fixture(setup_error_fixture):
pass
""")