]> 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 b9e8e286677eb92038780396e7c26d327db9cd9a..c29bd8d2ec987cdaf41d279ee8ba08c1762e292a 100644 (file)
@@ -72,15 +72,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)
 
     @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.
-        for f in TemporaryFile(), TESTFN2:
+        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: