summaryrefslogtreecommitdiff
path: root/_pytest
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-10-02 12:39:01 +0200
committerholger krekel <holger@merlinux.eu>2013-10-02 12:39:01 +0200
commit071960250f6e52d37f8511dd2c5672967cb2e5e2 (patch)
tree15e9936ed8e80dcdb2874841aa96b78352974160 /_pytest
parent16d98541f254f62beb3b15655b3c47f8493bb3a1 (diff)
downloadpytest-071960250f6e52d37f8511dd2c5672967cb2e5e2.tar.gz
avoid "IOError: Bad Filedescriptor" on pytest shutdown by not closing
the internal dupped stdout (fix is slightly hand-wavy but work).
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/__init__.py2
-rw-r--r--_pytest/capture.py2
-rw-r--r--_pytest/terminal.py13
3 files changed, 10 insertions, 7 deletions
diff --git a/_pytest/__init__.py b/_pytest/__init__.py
index 1d5eb258a..9ff66d9a3 100644
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
#
-__version__ = '2.4.1'
+__version__ = '2.4.2.dev1'
diff --git a/_pytest/capture.py b/_pytest/capture.py
index 12291a5e3..be3194532 100644
--- a/_pytest/capture.py
+++ b/_pytest/capture.py
@@ -29,7 +29,7 @@ def pytest_load_initial_conftests(early_config, parser, args, __multicall__):
except ValueError:
pass
early_config.pluginmanager.add_shutdown(teardown)
- # make sure logging does not raise exceptions if it is imported
+ # make sure logging does not raise exceptions at the end
def silence_logging_at_shutdown():
if "logging" in sys.modules:
sys.modules["logging"].raiseExceptions = False
diff --git a/_pytest/terminal.py b/_pytest/terminal.py
index e55390a23..db7136ea2 100644
--- a/_pytest/terminal.py
+++ b/_pytest/terminal.py
@@ -33,20 +33,23 @@ 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. (unless capturing is turned off)
- stdout = py.std.sys.stdout
- capture = config.option.capture != "no"
- if capture and hasattr(os, 'dup') and hasattr(stdout, 'fileno'):
+ # later changes on FD level. (unless capturing is off/sys)
+ stdout = sys.stdout
+ if config.option.capture == "fd" and hasattr(os, "dup"):
try:
newstdout = py.io.dupfile(stdout, buffering=1,
encoding=stdout.encoding)
except ValueError:
pass
else:
- config._cleanup.append(lambda: newstdout.close())
assert stdout.encoding == newstdout.encoding
stdout = newstdout
+ #we don't close on shutdown because this can
+ #cause logging to fail on a second close
+ #(not really clear to me how it happens exactly, though)
+ #config.pluginmanager.add_shutdown(fin)
reporter = TerminalReporter(config, stdout)
config.pluginmanager.register(reporter, 'terminalreporter')