dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00380
[PATCH v2 6/6] test_pack.TestPack.test_copy: close packs
---
dulwich/tests/test_pack.py | 39 ++++++++++++++++++++++++---------------
1 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/dulwich/tests/test_pack.py b/dulwich/tests/test_pack.py
index f2467f8..7a375a3 100644
--- a/dulwich/tests/test_pack.py
+++ b/dulwich/tests/test_pack.py
@@ -272,21 +272,30 @@ class TestPack(PackTests):
def test_copy(self):
origpack = self.get_pack(pack1_sha)
- self.assertSucceeds(origpack.index.check)
- basename = os.path.join(self.tempdir, 'Elch')
- write_pack(basename, [(x, '') for x in origpack.iterobjects()],
- len(origpack))
- newpack = Pack(basename)
- self.assertEquals(origpack, newpack)
- self.assertSucceeds(newpack.index.check)
- self.assertEquals(origpack.name(), newpack.name())
- self.assertEquals(origpack.index.get_pack_checksum(),
- newpack.index.get_pack_checksum())
-
- wrong_version = origpack.index.version != newpack.index.version
- orig_checksum = origpack.index.get_stored_checksum()
- new_checksum = newpack.index.get_stored_checksum()
- self.assertTrue(wrong_version or orig_checksum == new_checksum)
+
+ try:
+ self.assertSucceeds(origpack.index.check)
+ basename = os.path.join(self.tempdir, 'Elch')
+ write_pack(basename, [(x, '') for x in origpack.iterobjects()],
+ len(origpack))
+ newpack = Pack(basename)
+
+ try:
+ self.assertEquals(origpack, newpack)
+ self.assertSucceeds(newpack.index.check)
+ self.assertEquals(origpack.name(), newpack.name())
+ self.assertEquals(origpack.index.get_pack_checksum(),
+ newpack.index.get_pack_checksum())
+
+ wrong_version = origpack.index.version != newpack.index.version
+ orig_checksum = origpack.index.get_stored_checksum()
+ new_checksum = newpack.index.get_stored_checksum()
+ self.assertTrue(wrong_version or orig_checksum == new_checksum)
+ finally:
+ newpack.close()
+ finally:
+ origpack.close()
+
def test_commit_obj(self):
p = self.get_pack(pack1_sha)
--
1.7.3.2.msysgit.0
References