From 70fc7df6eb0a14f845e1e7657d8ff782a2f6c1e1 Mon Sep 17 00:00:00 2001 From: gholt Date: Mon, 16 Dec 2013 17:14:00 +0000 Subject: [PATCH] Just trying to keep /tmp clean Change-Id: Ia8d7cf37a4f6a4652cb3440a896cefb411cdb41a --- test/unit/obj/test_diskfile.py | 13 ++++++++++--- test/unit/obj/test_ssync_sender.py | 8 ++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index a0e954e6cf..7ce39a1d62 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -531,7 +531,9 @@ class TestObjectAuditLocationGenerator(unittest.TestCase): class TestDiskFileManager(unittest.TestCase): def setUp(self): - self.testdir = os.path.join(mkdtemp(), 'tmp_test_obj_server_DiskFile') + self.tmpdir = mkdtemp() + self.testdir = os.path.join( + self.tmpdir, 'tmp_test_obj_server_DiskFile') mkdirs(os.path.join(self.testdir, 'sda1', 'tmp')) mkdirs(os.path.join(self.testdir, 'sda2', 'tmp')) self._orig_tpool_exc = tpool.execute @@ -540,6 +542,9 @@ class TestDiskFileManager(unittest.TestCase): keep_cache_size=2 * 1024) self.df_mgr = diskfile.DiskFileManager(self.conf, FakeLogger()) + def tearDown(self): + rmtree(self.tmpdir, ignore_errors=1) + def test_replication_lock_on(self): # Double check settings self.df_mgr.replication_one_per_device = True @@ -599,7 +604,9 @@ class TestDiskFile(unittest.TestCase): def setUp(self): """Set up for testing swift.obj.diskfile""" - self.testdir = os.path.join(mkdtemp(), 'tmp_test_obj_server_DiskFile') + self.tmpdir = mkdtemp() + self.testdir = os.path.join( + self.tmpdir, 'tmp_test_obj_server_DiskFile') mkdirs(os.path.join(self.testdir, 'sda1', 'tmp')) self._orig_tpool_exc = tpool.execute tpool.execute = lambda f, *args, **kwargs: f(*args, **kwargs) @@ -609,7 +616,7 @@ class TestDiskFile(unittest.TestCase): def tearDown(self): """Tear down for testing swift.obj.diskfile""" - rmtree(os.path.dirname(self.testdir)) + rmtree(self.tmpdir, ignore_errors=1) tpool.execute = self._orig_tpool_exc def _create_ondisk_file(self, df, data, timestamp, metadata=None, diff --git a/test/unit/obj/test_ssync_sender.py b/test/unit/obj/test_ssync_sender.py index 7b6b354749..848ca83004 100644 --- a/test/unit/obj/test_ssync_sender.py +++ b/test/unit/obj/test_ssync_sender.py @@ -15,6 +15,7 @@ import hashlib import os +import shutil import StringIO import tempfile import time @@ -92,11 +93,14 @@ class FakeConnection(object): class TestSender(unittest.TestCase): def setUp(self): - self.testdir = os.path.join( - tempfile.mkdtemp(), 'tmp_test_ssync_sender') + self.tmpdir = tempfile.mkdtemp() + self.testdir = os.path.join(self.tmpdir, 'tmp_test_ssync_sender') self.replicator = FakeReplicator(self.testdir) self.sender = ssync_sender.Sender(self.replicator, None, None, None) + def tearDown(self): + shutil.rmtree(self.tmpdir, ignore_errors=1) + def _make_open_diskfile(self, device='dev', partition='9', account='a', container='c', obj='o', body='test', extra_metadata=None):