In LogTrapTestCase, leave everything alone rather than throwing an exception

if the logging config is not as expected.
This commit is contained in:
Ben Darnell 2010-08-15 18:11:48 -07:00
parent 551ea94d24
commit 221058e1cb
1 changed files with 6 additions and 0 deletions

View File

@ -246,6 +246,12 @@ class LogTrapTestCase(unittest.TestCase):
""" """
def run(self, result=None): def run(self, result=None):
logger = logging.getLogger() logger = logging.getLogger()
if len(logger.handlers) > 1:
# Multiple handlers have been defined. It gets messy to handle
# this, especially since the handlers may have different
# formatters. Just leave the logging alone in this case.
super(LogTrapTestCase, self).run(result)
return
if not logger.handlers: if not logger.handlers:
logging.basicConfig() logging.basicConfig()
self.assertEqual(len(logger.handlers), 1) self.assertEqual(len(logger.handlers), 1)