From 23ffde81a5af03b6f548b762f8a0632014971884 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Thu, 27 Oct 2016 11:46:09 -0400 Subject: [PATCH] Fix test_unwatch_log() to cleanup after itself Use get_temp_file_patch() so a unique directory is used for test files, and so that anything created will get cleaned-up on completion. Change-Id: Ie3473906f87fdf270f1a67c16ed511b38b597755 --- neutron/tests/unit/agent/linux/test_daemon.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/neutron/tests/unit/agent/linux/test_daemon.py b/neutron/tests/unit/agent/linux/test_daemon.py index c093909f05a..5730df2f40f 100644 --- a/neutron/tests/unit/agent/linux/test_daemon.py +++ b/neutron/tests/unit/agent/linux/test_daemon.py @@ -37,10 +37,11 @@ class FakeEntry(object): class TestUnwatchLog(base.BaseTestCase): def test_unwatch_log(self): + temp_file_name = self.get_temp_file_path('unwatch_log_temp_file_name') stream_handler = logging.StreamHandler() logger = logging.Logger('fake') 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): daemon.unwatch_log() @@ -48,7 +49,7 @@ class TestUnwatchLog(base.BaseTestCase): logger.handlers.remove(stream_handler) observed = logger.handlers[0] self.assertEqual(logging.FileHandler, type(observed)) - self.assertEqual('/tmp/filename1', observed.baseFilename) + self.assertEqual(temp_file_name, observed.baseFilename) class TestPrivileges(base.BaseTestCase):