Commit 359b97aa authored by Chris McDonough's avatar Chris McDonough

Fix failing tests and make more assertions about logger levels.

parent 314a97b9
...@@ -105,20 +105,27 @@ class ZopeStarterTestCase(unittest.TestCase): ...@@ -105,20 +105,27 @@ class ZopeStarterTestCase(unittest.TestCase):
path <<INSTANCE_HOME>>/event.log path <<INSTANCE_HOME>>/event.log
level info level info
</logfile> </logfile>
<logfile>
path <<INSTANCE_HOME>>/event2.log
level blather
</logfile>
</eventlog>""") </eventlog>""")
starter = ZopeStarter(conf) starter = ZopeStarter(conf)
self.assertEqual(zLOG.EventLogger.EventLogger.logger.level,
logging.NOTSET)
starter.setupStartupHandler() starter.setupStartupHandler()
self.assert_(not zLOG._call_initialize) self.assert_(not zLOG._call_initialize)
self.assertEqual(starter.startup_handler.formatter, self.assertEqual(starter.startup_handler.formatter,
zLOG.EventLogger.formatters['file']) zLOG.EventLogger.formatters['file'])
self.assertEqual(starter.startup_handler.level,
logging.DEBUG) # startup handler should take on the level of the event log handler
# with the lowest level
self.assertEqual(starter.startup_handler.level, 15) # 15 is BLATHER
self.assertEqual(starter.startup_handler, self.assertEqual(starter.startup_handler,
zLOG.EventLogger.EventLogger.logger.handlers[0]) zLOG.EventLogger.EventLogger.logger.handlers[0])
self.assertEqual(len(zLOG.EventLogger.EventLogger.logger.handlers), 1)
self.assertEqual(zLOG.EventLogger.EventLogger.logger.level, self.assertEqual(zLOG.EventLogger.EventLogger.logger.level,
logging.DEBUG) 15)
self.assertEqual(starter.startup_handler.level, logging.DEBUG) self.assertEqual(len(zLOG.EventLogger.EventLogger.logger.handlers), 1)
self.failUnlessEqual(starter.startup_handler.stream, sys.stderr) self.failUnlessEqual(starter.startup_handler.stream, sys.stderr)
conf = self.load_config_text(""" conf = self.load_config_text("""
instancehome <<INSTANCE_HOME>> instancehome <<INSTANCE_HOME>>
...@@ -230,7 +237,7 @@ class ZopeStarterTestCase(unittest.TestCase): ...@@ -230,7 +237,7 @@ class ZopeStarterTestCase(unittest.TestCase):
import sys import sys
conf = self.load_config_text(""" conf = self.load_config_text("""
instancehome <<INSTANCE_HOME>> instancehome <<INSTANCE_HOME>>
debug-mode off debug-mode off
<eventlog> <eventlog>
level info level info
<logfile> <logfile>
...@@ -252,11 +259,15 @@ class ZopeStarterTestCase(unittest.TestCase): ...@@ -252,11 +259,15 @@ class ZopeStarterTestCase(unittest.TestCase):
</logger> </logger>
""") """)
try: try:
self.assertEqual(zLOG.EventLogger.EventLogger.logger.level,
logging.NOTSET)
starter = ZopeStarter(conf) starter = ZopeStarter(conf)
starter.setupStartupHandler() starter.setupStartupHandler()
starter.info('hello') starter.info('hello')
starter.removeStartupHandler() starter.removeStartupHandler()
starter.setupConfiguredLoggers() starter.setupConfiguredLoggers()
self.assertEqual(zLOG.EventLogger.EventLogger.logger.level,
logging.INFO)
starter.flushStartupHandlerBuffer() starter.flushStartupHandlerBuffer()
l = open(os.path.join(TEMPNAME, 'event.log')).read() l = open(os.path.join(TEMPNAME, 'event.log')).read()
self.failUnless(l.find('hello') > -1) self.failUnless(l.find('hello') > -1)
......
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