]> granicus.if.org Git - python/commitdiff
Implement #7944. Use `with` throughout the test suite.
authorBrian Curtin <brian.curtin@gmail.com>
Wed, 13 Oct 2010 02:40:26 +0000 (02:40 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Wed, 13 Oct 2010 02:40:26 +0000 (02:40 +0000)
Lib/test/test_marshal.py

index 9de0165e291744ee86e94b65529862ae7212314c..a79a357c41395cdc03aa5916841366cfa85b4ab0 100644 (file)
@@ -11,16 +11,10 @@ class HelperMixin:
         new = marshal.loads(marshal.dumps(sample, *extra))
         self.assertEqual(sample, new)
         try:
-            f = open(support.TESTFN, "wb")
-            try:
+            with open(support.TESTFN, "wb") as f:
                 marshal.dump(sample, f, *extra)
-            finally:
-                f.close()
-            f = open(support.TESTFN, "rb")
-            try:
+            with open(support.TESTFN, "rb") as f:
                 new = marshal.load(f)
-            finally:
-                f.close()
             self.assertEqual(sample, new)
         finally:
             support.unlink(support.TESTFN)