fixed some calls to get_logger that didn't clean up after themselves
This commit is contained in:
parent
c007d0296e
commit
ab53587796
@ -79,14 +79,6 @@ class TestUtils(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
utils.HASH_PATH_SUFFIX = 'endcap'
|
utils.HASH_PATH_SUFFIX = 'endcap'
|
||||||
self.logger = logging.getLogger()
|
|
||||||
self.starting_handlers = list(self.logger.handlers)
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
# don't let extra handlers pile up redirecting stdio and other stuff...
|
|
||||||
for handler in self.logger.handlers:
|
|
||||||
if handler not in self.starting_handlers:
|
|
||||||
self.logger.removeHandler(handler)
|
|
||||||
|
|
||||||
def test_normalize_timestamp(self):
|
def test_normalize_timestamp(self):
|
||||||
""" Test swift.common.utils.normalize_timestamp """
|
""" Test swift.common.utils.normalize_timestamp """
|
||||||
@ -178,7 +170,6 @@ class TestUtils(unittest.TestCase):
|
|||||||
self.assertEquals(sio.getvalue(), '')
|
self.assertEquals(sio.getvalue(), '')
|
||||||
|
|
||||||
def test_LoggerFileObject(self):
|
def test_LoggerFileObject(self):
|
||||||
reload(sys) # reset stdio redirection
|
|
||||||
orig_stdout = sys.stdout
|
orig_stdout = sys.stdout
|
||||||
orig_stderr = sys.stderr
|
orig_stderr = sys.stderr
|
||||||
sio = StringIO()
|
sio = StringIO()
|
||||||
@ -436,13 +427,11 @@ log_name = yarr'''
|
|||||||
self.assert_(utils.sys.excepthook is not None)
|
self.assert_(utils.sys.excepthook is not None)
|
||||||
# when logging to console, stderr remains open
|
# when logging to console, stderr remains open
|
||||||
self.assertEquals(utils.os.closed_fds, [0, 1])
|
self.assertEquals(utils.os.closed_fds, [0, 1])
|
||||||
|
logger.logger.removeHandler(utils.get_logger.console)
|
||||||
# stdio not captured
|
# stdio not captured
|
||||||
self.assertFalse(hasattr(utils.sys, 'stdout'))
|
self.assertFalse(hasattr(utils.sys, 'stdout'))
|
||||||
self.assertFalse(hasattr(utils.sys, 'stderr'))
|
self.assertFalse(hasattr(utils.sys, 'stderr'))
|
||||||
|
|
||||||
# reset mocks on utils
|
|
||||||
reload(utils)
|
|
||||||
|
|
||||||
def test_get_logger_console(self):
|
def test_get_logger_console(self):
|
||||||
reload(utils) # reset get_logger attrs
|
reload(utils) # reset get_logger attrs
|
||||||
logger = utils.get_logger(None)
|
logger = utils.get_logger(None)
|
||||||
@ -455,6 +444,7 @@ log_name = yarr'''
|
|||||||
old_handler = utils.get_logger.console
|
old_handler = utils.get_logger.console
|
||||||
logger = utils.get_logger(None, log_to_console=True)
|
logger = utils.get_logger(None, log_to_console=True)
|
||||||
self.assertNotEquals(utils.get_logger.console, old_handler)
|
self.assertNotEquals(utils.get_logger.console, old_handler)
|
||||||
|
logger.logger.removeHandler(utils.get_logger.console)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user