fix resource leaks building recovery index
[python-delta-tar] / testing / test_concat_compress.py
index 84f47ba..b2539b9 100644 (file)
@@ -90,11 +90,12 @@ class ConcatCompressTest(BaseTest):
         tarobj.close()
         os.unlink("big")
 
-        fo = open("sample.tar.gz", 'rb')
+        fo = open("sample.tar.gz", 'rb') # will not be released on tarfile.close()
         fo.seek(pos)
         tarobj = TarFile.open(mode="r#gz", fileobj=fo)
         tarobj.extract(tarobj.next())
         tarobj.close()
+        fo.close()
         assert os.path.exists("big")
         assert hash == self.md5sum("big")
 
@@ -126,11 +127,12 @@ class ConcatCompressTest(BaseTest):
         os.unlink("small2")
 
         # extract only the "small" file
-        fo = open("sample.tar.gz", 'rb')
+        fo = open("sample.tar.gz", 'rb') # will not be released on tarfile.close()
         fo.seek(pos)
         tarobj = TarFile.open(mode="r#gz", fileobj=fo)
         tarobj.extract(tarobj.next())
         tarobj.close()
+        fo.close()
         assert os.path.exists("small")
         assert hash['small'] == self.md5sum("small")
 
@@ -174,12 +176,13 @@ class ConcatCompressTest(BaseTest):
             tarobj.open_volume(volume_path)
 
         # extract only the "small" file
-        fo = open("sample.tar.gz", 'rb')
+        fo = open("sample.tar.gz", 'rb') # will not be released on tarfile.close()
         fo.seek(pos)
         tarobj = TarFile.open(mode="r#gz", fileobj=fo,
                               new_volume_handler=new_volume_handler_fo)
         tarobj.extract(tarobj.next())
         tarobj.close()
+        fo.close()
         assert os.path.exists("big")
         assert hash['big'] == self.md5sum("big")