Convert some try/finally to addCleanup

This commit is contained in:
Ned Batchelder
2015-03-22 07:26:21 -04:00
parent cb0624bfa1
commit e6e5a8d812
3 changed files with 22 additions and 36 deletions

View File

@@ -175,14 +175,12 @@ class CommandsTestBase(ModuleStoreTestCase):
def test_export_course(self):
tmp_dir = path(mkdtemp())
self.addCleanup(shutil.rmtree, tmp_dir)
filename = tmp_dir / 'test.tar.gz'
try:
self.run_export_course(filename)
with tarfile.open(filename) as tar_file:
self.check_export_file(tar_file)
finally:
shutil.rmtree(tmp_dir)
self.run_export_course(filename)
with tarfile.open(filename) as tar_file:
self.check_export_file(tar_file)
def test_export_course_stdout(self):
output = self.run_export_course('-')