avoid "IOError: Bad Filedescriptor" on pytest shutdown by not closing
the internal dupped stdout (fix is slightly hand-wavy but work).
This commit is contained in:
parent
16d98541f2
commit
071960250f
|
@ -1,3 +1,9 @@
|
||||||
|
Changes between 2.4.1 and 2.4.2
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
- avoid "IOError: Bad Filedescriptor" on pytest shutdown by not closing
|
||||||
|
the internal dupped stdout (fix is slightly hand-wavy but work).
|
||||||
|
|
||||||
Changes between 2.4.0 and 2.4.1
|
Changes between 2.4.0 and 2.4.1
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#
|
#
|
||||||
__version__ = '2.4.1'
|
__version__ = '2.4.2.dev1'
|
||||||
|
|
|
@ -29,7 +29,7 @@ def pytest_load_initial_conftests(early_config, parser, args, __multicall__):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
early_config.pluginmanager.add_shutdown(teardown)
|
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():
|
def silence_logging_at_shutdown():
|
||||||
if "logging" in sys.modules:
|
if "logging" in sys.modules:
|
||||||
sys.modules["logging"].raiseExceptions = False
|
sys.modules["logging"].raiseExceptions = False
|
||||||
|
|
|
@ -33,20 +33,23 @@ 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. (unless capturing is turned off)
|
# later changes on FD level. (unless capturing is off/sys)
|
||||||
stdout = py.std.sys.stdout
|
stdout = sys.stdout
|
||||||
capture = config.option.capture != "no"
|
if config.option.capture == "fd" and hasattr(os, "dup"):
|
||||||
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)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
config._cleanup.append(lambda: newstdout.close())
|
|
||||||
assert stdout.encoding == newstdout.encoding
|
assert stdout.encoding == newstdout.encoding
|
||||||
stdout = newstdout
|
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)
|
reporter = TerminalReporter(config, stdout)
|
||||||
config.pluginmanager.register(reporter, 'terminalreporter')
|
config.pluginmanager.register(reporter, 'terminalreporter')
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ def main():
|
||||||
name='pytest',
|
name='pytest',
|
||||||
description='py.test: simple powerful testing with Python',
|
description='py.test: simple powerful testing with Python',
|
||||||
long_description = long_description,
|
long_description = long_description,
|
||||||
version='2.4.1',
|
version='2.4.2.dev1',
|
||||||
url='http://pytest.org',
|
url='http://pytest.org',
|
||||||
license='MIT license',
|
license='MIT license',
|
||||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||||
|
|
Loading…
Reference in New Issue