Testing: use try/finally to ensure repo.json is always cleaned up

This commit is contained in:
gandalf3
2017-06-29 02:18:52 -07:00
parent 5a0aba8a56
commit 2268925733

View File

@@ -31,11 +31,12 @@ class test_blenderpack_make_repo(unittest.TestCase):
blenderpack.make_repo(self.helper_path / 'addons') blenderpack.make_repo(self.helper_path / 'addons')
repojson = self.helper_path / 'addons' / 'repo.json' repojson = self.helper_path / 'addons' / 'repo.json'
self.assertTrue(repojson.is_file()) try:
with repojson.open('r') as f: with repojson.open('r') as f:
json.loads(f.read()) json.loads(f.read())
finally:
repojson.unlink()
os.remove(repojson)
self.fail('unfinished test') self.fail('unfinished test')
def test_make_repo_from_nonexistent(self): def test_make_repo_from_nonexistent(self):