fix logging interaction issue

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-07-09 13:12:00 +02:00
parent 8a085c035a
commit 605f36c905
3 changed files with 24 additions and 0 deletions

View File

@ -1,6 +1,9 @@
Changes between 1.0.0b7 and 1.0.0b8
=====================================
* workaround a logging module interaction ("closing already closed
files"). Thanks to Sridhar Ratnakumar for triggering.
* if plugins use "py.test.importorskip" for importing
a dependency only a warning will be issued instead
of exiting the testing process.

View File

@ -24,6 +24,13 @@ def pytest_sessionfinish(session, exitstatus, excrepr=None):
if hasattr(session.config, '_setupstate'):
session.config._setupstate.teardown_all()
# prevent logging module atexit handler from choking on
# its attempt to close already closed streams
# see http://bugs.python.org/issue6333
mod = py.std.sys.modules.get("logging", None)
if mod is not None:
mod.raiseExceptions = False
def pytest_make_collect_report(collector):
call = collector.config.guardedcall(
lambda: collector._memocollect()

View File

@ -286,3 +286,17 @@ def test_functional_boxed(testdir):
"*CRASHED*",
"*1 failed*"
])
def test_logging_interaction(testdir):
p = testdir.makepyfile("""
def test_logging():
import logging
import StringIO
stream = StringIO.StringIO()
logging.basicConfig(stream=stream)
stream.close() # to free memory/release resources
""")
result = testdir.runpytest(p)
assert result.stderr.str().find("atexit") == -1