always dupfile if os.dup is available
This commit is contained in:
parent
2248a31a44
commit
ae090740c5
|
@ -37,7 +37,7 @@ def pytest_configure(config):
|
||||||
# we try hard to make printing resilient against
|
# we try hard to make printing resilient against
|
||||||
# later changes on FD level. (unless capturing is off/sys)
|
# later changes on FD level. (unless capturing is off/sys)
|
||||||
stdout = sys.stdout
|
stdout = sys.stdout
|
||||||
if config.option.capture == "fd" and hasattr(os, "dup"):
|
if hasattr(os, "dup"):
|
||||||
try:
|
try:
|
||||||
newstdout = py.io.dupfile(stdout, buffering=1,
|
newstdout = py.io.dupfile(stdout, buffering=1,
|
||||||
encoding=stdout.encoding)
|
encoding=stdout.encoding)
|
||||||
|
|
|
@ -677,14 +677,6 @@ 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("""
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -712,3 +704,14 @@ def test_terminal_summary(testdir):
|
||||||
*==== hello ====*
|
*==== hello ====*
|
||||||
world
|
world
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
@pytest.mark.xfail("not hasattr(os, 'dup')")
|
||||||
|
def test_fd_fixing(testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import os
|
||||||
|
os.close(1)
|
||||||
|
def test_fdclose():
|
||||||
|
os.close(2)
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest("-s")
|
||||||
|
result.stdout.fnmatch_lines("*1 pass*")
|
||||||
|
|
Loading…
Reference in New Issue