Commit 0a3f06d8 authored by Tres Seaver's avatar Tres Seaver

Suppress bogus handler errors.

parent 11166dce
...@@ -54,6 +54,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -54,6 +54,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
schema = None schema = None
def setUp(self): def setUp(self):
from ZConfig.components.logger import loghandler
if self.schema is None: if self.schema is None:
ZopeStarterTestCase.schema = getSchema() ZopeStarterTestCase.schema = getSchema()
test_logger.LoggingTestBase.setUp(self) test_logger.LoggingTestBase.setUp(self)
...@@ -66,12 +67,18 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -66,12 +67,18 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
pass pass
Products.__path__ = [d for d in Products.__path__ Products.__path__ = [d for d in Products.__path__
if os.path.exists(d)] if os.path.exists(d)]
test_logger.LoggingTestBase.tearDown(self) test_logger.LoggingTestBase.tearDown(self)
# reset logger states # reset logger states
for name in (None, 'access', 'trace'): for name in (None, 'access', 'trace'):
logger = logging.getLogger(name) logger = logging.getLogger(name)
logger.__dict__.update(logger_states[name]) logger.__dict__.update(logger_states[name])
def _clearHandlers(self):
from ZConfig.components.logger import loghandler
del loghandler._reopenable_handlers[:]
def get_starter(self, conf): def get_starter(self, conf):
starter = Zope2.Startup.get_starter() starter = Zope2.Startup.get_starter()
starter.setConfiguration(conf) starter.setConfiguration(conf)
...@@ -144,6 +151,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -144,6 +151,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
self.assertEqual(logger.level, 15) self.assertEqual(logger.level, 15)
# We expect a debug handler and the startup handler: # We expect a debug handler and the startup handler:
self.assertEqual(len(logger.handlers), 2) self.assertEqual(len(logger.handlers), 2)
# XXX need to check that log messages get written to # XXX need to check that log messages get written to
# sys.stderr, not that the stream identity for the startup # sys.stderr, not that the stream identity for the startup
# handler matches # handler matches
...@@ -312,6 +320,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -312,6 +320,7 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
os.unlink(os.path.join(TEMPNAME, name)) os.unlink(os.path.join(TEMPNAME, name))
except: except:
pass pass
self._clearHandlers()
def testMakeLockFile(self): def testMakeLockFile(self):
# put something in the way (it should be deleted) # put something in the way (it should be deleted)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment