]> granicus.if.org Git - python/commitdiff
Issue #25801: Fixed resource warnings in test_zipfile64.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 25 Feb 2016 10:55:19 +0000 (12:55 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 25 Feb 2016 10:55:19 +0000 (12:55 +0200)
Patch by SilentGhost.

Lib/test/test_zipfile64.py

index a87baaa8991d899d6dee9a5458aa2b6038727384..151baf2302349ab22ebc51f7d11bdb112a37e855 100644 (file)
@@ -79,15 +79,19 @@ class TestsWithSourceFile(unittest.TestCase):
     def testStored(self):
         # Try the temp file first.  If we do TESTFN2 first, then it hogs
         # gigabytes of disk space for the duration of the test.
-        for f in TemporaryFile(), TESTFN2:
+        with TemporaryFile() as f:
             self.zipTest(f, zipfile.ZIP_STORED)
+            self.assertFalse(f.closed)
+        self.zipTest(TESTFN2, zipfile.ZIP_STORED)
 
-    if zlib:
-        def testDeflated(self):
-            # Try the temp file first.  If we do TESTFN2 first, then it hogs
-            # gigabytes of disk space for the duration of the test.
-            for f in TemporaryFile(), TESTFN2:
-                self.zipTest(f, zipfile.ZIP_DEFLATED)
+    @unittest.skipUnless(zlib, "requires zlib")
+    def testDeflated(self):
+        # Try the temp file first.  If we do TESTFN2 first, then it hogs
+        # gigabytes of disk space for the duration of the test.
+        with TemporaryFile() as f:
+            self.zipTest(f, zipfile.ZIP_DEFLATED)
+            self.assertFalse(f.closed)
+        self.zipTest(TESTFN2, zipfile.ZIP_DEFLATED)
 
     def tearDown(self):
         for fname in TESTFN, TESTFN2: