mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
Fix file closing in test_http_cookiejar.
This commit is contained in:
parent
918e2d4832
commit
7f462fc835
1 changed files with 5 additions and 5 deletions
|
|
@ -263,11 +263,11 @@ def test_bad_magic(self):
|
|||
# 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue