don't manipulate FDs at all if output capturing is turned off.
This commit is contained in:
parent
3ab9b48782
commit
030c337c68
|
@ -34,9 +34,10 @@ def pytest_addoption(parser):
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
config.option.verbose -= config.option.quiet
|
config.option.verbose -= config.option.quiet
|
||||||
# we try hard to make printing resilient against
|
# 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
|
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:
|
try:
|
||||||
newstdout = py.io.dupfile(stdout, buffering=1,
|
newstdout = py.io.dupfile(stdout, buffering=1,
|
||||||
encoding=stdout.encoding)
|
encoding=stdout.encoding)
|
||||||
|
|
|
@ -677,6 +677,13 @@ def test_fdopen_kept_alive_issue124(testdir):
|
||||||
"*2 passed*"
|
"*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):
|
def test_tbstyle_native_setup_error(testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
|
|
Loading…
Reference in New Issue