From 0e51ac09ada654917cd667f81bec8391f28407d2 Mon Sep 17 00:00:00 2001 From: Alistair Coles Date: Fri, 1 Sep 2017 15:28:30 +0100 Subject: [PATCH] Cleanup test tempdirs in tearDown Stop leaking tmp dirs in unit tests Change-Id: I606e9deeedc7c52a85d270b3cef7dfba13b4f0d3 --- test/unit/container/test_sync_store.py | 2 +- test/unit/proxy/test_server.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/unit/container/test_sync_store.py b/test/unit/container/test_sync_store.py index 20f0268b5d..0082d7a83c 100644 --- a/test/unit/container/test_sync_store.py +++ b/test/unit/container/test_sync_store.py @@ -69,7 +69,7 @@ class TestContainerSyncStore(unittest.TestCase): with open(db_file, 'w') as outfile: outfile.write('%s' % db_file) - def teardown(self): + def tearDown(self): rmtree(self.test_dir_prefix) def pick_dbfile(self): diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 7f3e9c5be7..2766ebea22 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -6603,10 +6603,16 @@ class TestECMismatchedFA(unittest.TestCase): class TestECGets(unittest.TestCase): + def setUp(self): + super(TestECGets, self).setUp() + self.tempdir = mkdtemp() + def tearDown(self): + rmtree(self.tempdir, ignore_errors=True) prosrv = _test_servers[0] # don't leak error limits and poison other tests prosrv._error_limiting = {} + super(TestECGets, self).tearDown() def _setup_nodes_and_do_GET(self, objs, node_state): """ @@ -6666,7 +6672,7 @@ class TestECGets(unittest.TestCase): # move all hash dir files to per-node, per-obj tempdir for node_index, hash_dir in node_hash_dirs.items(): - node_tmp_dirs[node_index][ref] = mkdtemp() + node_tmp_dirs[node_index][ref] = mkdtemp(dir=self.tempdir) for f in os.listdir(hash_dir): move(os.path.join(hash_dir, f), os.path.join(node_tmp_dirs[node_index][ref], f))