clean temp dir in /tmp

In unit tests, many test class use tempfile.mkdtemp in SetUp and
shutil.rmtree in tearDown.

A common wrong case is putting test data in `testdir = os.join(mkdtemp() +
'some_class')` and `rmmtree(testdir)`. As a result, /tmp/xxx/some_class
was deleted, but /tmp/xxx is still leaved in system. So a proper fix is
`rmtree(os.path.dirname(testdir), ignore_errors=1)`

fixes bug #1212583

Change-Id: Iafbe3e11f16b51bdf49abce9e68eb01f25bc5df2
This commit is contained in:
Kun Huang 2013-08-15 16:10:11 +08:00 committed by Kun Huang
parent 8a8499805b
commit 4ef993735b

@ -105,12 +105,11 @@ class TestUntar(unittest.TestCase):
def setUp(self):
self.app = FakeApp()
self.bulk = bulk.filter_factory({})(self.app)
self.testdir = os.path.join(mkdtemp(), 'tmp_test_bulk')
os.mkdir(self.testdir)
self.testdir = mkdtemp(suffix='tmp_test_bulk')
def tearDown(self):
self.app.calls = 0
rmtree(self.testdir)
rmtree(self.testdir, ignore_errors=1)
def handle_extract_and_iter(self, req, compress_format,
out_content_type='application/json'):