diff --git a/_pytest/terminal.py b/_pytest/terminal.py index db7136ea2..1e928dc7d 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -37,7 +37,7 @@ def pytest_configure(config): # we try hard to make printing resilient against # later changes on FD level. (unless capturing is off/sys) stdout = sys.stdout - if config.option.capture == "fd" and hasattr(os, "dup"): + if hasattr(os, "dup"): try: newstdout = py.io.dupfile(stdout, buffering=1, encoding=stdout.encoding) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 3a0693d97..3b4be7be6 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -677,14 +677,6 @@ 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(""" import pytest @@ -712,3 +704,14 @@ def test_terminal_summary(testdir): *==== hello ====* 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*")