From 2c3563f7827ad6d6a726fabd2352597924af1e78 Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Wed, 13 Oct 2010 02:40:26 +0000 Subject: [PATCH] Implement #7944. Use `with` throughout the test suite. --- Lib/test/test_marshal.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 9de0165e29..a79a357c41 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -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) -- 2.40.0