From 7f462fc8351ba4e02a12ff9a81df3e84324a4130 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 29 Oct 2010 23:27:39 +0000 Subject: Fix file closing in test_http_cookiejar. --- Lib/test/test_http_cookiejar.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_http_cookiejar.py b/Lib/test/test_http_cookiejar.py index c867bbc..fca6710 100644 --- a/Lib/test/test_http_cookiejar.py +++ b/Lib/test/test_http_cookiejar.py @@ -263,11 +263,11 @@ class FileCookieJarTests(unittest.TestCase): # Invalid contents of cookies file (eg. bad magic string) # causes a LoadError. try: - f = open(filename, "w") - f.write("oops\n") - for cookiejar_class in LWPCookieJar, MozillaCookieJar: - c = cookiejar_class() - self.assertRaises(LoadError, c.load, filename) + with open(filename, "w") as f: + f.write("oops\n") + for cookiejar_class in LWPCookieJar, MozillaCookieJar: + c = cookiejar_class() + self.assertRaises(LoadError, c.load, filename) finally: try: os.unlink(filename) except OSError: pass -- cgit v0.12