Merge "Fix test_unwatch_log() to cleanup after itself"
This commit is contained in:
commit
c8e6b032f9
@ -37,10 +37,11 @@ class FakeEntry(object):
|
|||||||
class TestUnwatchLog(base.BaseTestCase):
|
class TestUnwatchLog(base.BaseTestCase):
|
||||||
|
|
||||||
def test_unwatch_log(self):
|
def test_unwatch_log(self):
|
||||||
|
temp_file_name = self.get_temp_file_path('unwatch_log_temp_file_name')
|
||||||
stream_handler = logging.StreamHandler()
|
stream_handler = logging.StreamHandler()
|
||||||
logger = logging.Logger('fake')
|
logger = logging.Logger('fake')
|
||||||
logger.addHandler(stream_handler)
|
logger.addHandler(stream_handler)
|
||||||
logger.addHandler(handlers.WatchedFileHandler('/tmp/filename1'))
|
logger.addHandler(handlers.WatchedFileHandler(temp_file_name))
|
||||||
|
|
||||||
with mock.patch('logging.getLogger', return_value=logger):
|
with mock.patch('logging.getLogger', return_value=logger):
|
||||||
daemon.unwatch_log()
|
daemon.unwatch_log()
|
||||||
@ -48,7 +49,7 @@ class TestUnwatchLog(base.BaseTestCase):
|
|||||||
logger.handlers.remove(stream_handler)
|
logger.handlers.remove(stream_handler)
|
||||||
observed = logger.handlers[0]
|
observed = logger.handlers[0]
|
||||||
self.assertEqual(logging.FileHandler, type(observed))
|
self.assertEqual(logging.FileHandler, type(observed))
|
||||||
self.assertEqual('/tmp/filename1', observed.baseFilename)
|
self.assertEqual(temp_file_name, observed.baseFilename)
|
||||||
|
|
||||||
|
|
||||||
class TestPrivileges(base.BaseTestCase):
|
class TestPrivileges(base.BaseTestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user