diff --git a/CHANGELOG b/CHANGELOG index 297b7f42704..baf05e64ad7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Changes between 2.0.0 and 2.0.1.dev1 ---------------------------------------------- +- fix issue8: no logging errors at process exit - refinements to "collecting" output on non-ttys - refine internal plugin registration and --traceconfig output - introduce a mechanism to prevent/unregister plugins from the diff --git a/_pytest/capture.py b/_pytest/capture.py index b35eef4b74a..d0fe3c9b0e3 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -26,7 +26,9 @@ def pytest_unconfigure(config): capman = config.pluginmanager.getplugin('capturemanager') while capman._method2capture: name, cap = capman._method2capture.popitem() - cap.reset() + # XXX logging module may wants to close it itself on process exit + # otherwise we could do finalization here and call "reset()". + cap.suspend() class NoCapture: def startall(self): diff --git a/_pytest/core.py b/_pytest/core.py index fcd7ea547ab..a8b5f90866c 100644 --- a/_pytest/core.py +++ b/_pytest/core.py @@ -151,15 +151,15 @@ def consider_setuptools_entrypoints(self): except ImportError: return # XXX issue a warning for ep in iter_entry_points('pytest11'): - if ep.name in self._name2plugin: + name = ep.name + if name.startswith("pytest_"): + name = name[7:] + if ep.name in self._name2plugin or name in self._name2plugin: continue try: plugin = ep.load() except DistributionNotFound: continue - name = ep.name - if name.startswith("pytest_"): - name = name[7:] self.register(plugin, name=name) def consider_preparse(self, args): diff --git a/testing/test_capture.py b/testing/test_capture.py index cc79f1f94f7..0080ef8e57b 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -306,6 +306,26 @@ def teardown_module(function): # verify proper termination assert "closed" not in s + def test_logging_initialized_in_test(self, testdir): + p = testdir.makepyfile(""" + import sys + def test_something(): + # pytest does not import logging + assert 'logging' not in sys.modules + import logging + logging.basicConfig() + logging.warn("hello432") + assert 0 + """) + result = testdir.runpytest(p, "--traceconfig", + "-p", "no:capturelog") + assert result.ret != 0 + result.stdout.fnmatch_lines([ + "*hello432*", + ]) + assert 'operation on closed file' not in result.stderr.str() + + class TestCaptureFuncarg: def test_std_functional(self, testdir): reprec = testdir.inline_runsource(""" diff --git a/tox.ini b/tox.ini index db04fc62dfb..0d7630ee57d 100644 --- a/tox.ini +++ b/tox.ini @@ -73,3 +73,4 @@ rsyncdirs=tox.ini pytest.py _pytest testing python_files=test_*.py *_test.py python_classes=Test Acceptance python_functions=test +pep8ignore = E401