Cleanup test tempdirs in tearDown

Stop leaking tmp dirs in unit tests

Change-Id: I606e9deeedc7c52a85d270b3cef7dfba13b4f0d3
This commit is contained in:
Alistair Coles 2017-09-01 15:28:30 +01:00
parent add2a94cd8
commit 0e51ac09ad
2 changed files with 8 additions and 2 deletions

View File

@ -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):

View File

@ -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))