Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use os_helper.unlink instead
  • Loading branch information
ambv committed Jun 8, 2022
commit 7caeea37660a486333d39457ec4105a59594ffe7
18 changes: 7 additions & 11 deletions Lib/test/test_http_cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ def test_lwp_valueless_cookie(self):
c = LWPCookieJar()
c.load(filename, ignore_discard=True)
finally:
try: os.unlink(filename)
except OSError: pass
os_helper.unlink(filename)
self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)

@unittest.skipIf(mswindows, "windows file permissions are incompatible with file modes")
Expand All @@ -383,7 +382,7 @@ def test_lwp_filepermissions(self):
st = os.stat(filename)
self.assertEqual(stat.S_IMODE(st.st_mode), 0o600)
finally:
test.support.unlink(filename)
os_helper.unlink(filename)

@unittest.skipIf(mswindows, "windows file permissions are incompatible with file modes")
@os_helper.skip_unless_working_chmod
Expand All @@ -397,7 +396,7 @@ def test_mozilla_filepermissions(self):
st = os.stat(filename)
self.assertEqual(stat.S_IMODE(st.st_mode), 0o600)
finally:
test.support.unlink(filename)
os_helper.unlink(filename)

def test_bad_magic(self):
# OSErrors (eg. file doesn't exist) are allowed to propagate
Expand All @@ -422,8 +421,7 @@ def test_bad_magic(self):
c = cookiejar_class()
self.assertRaises(LoadError, c.load, filename)
finally:
try: os.unlink(filename)
except OSError: pass
os_helper.unlink(filename)

class CookieTests(unittest.TestCase):
# XXX
Expand Down Expand Up @@ -527,7 +525,7 @@ def test_missing_value(self):
c = MozillaCookieJar(filename)
c.revert(ignore_expires=True, ignore_discard=True)
finally:
os.unlink(c.filename)
os_helper.unlink(c.filename)
# cookies unchanged apart from lost info re. whether path was specified
self.assertEqual(
repr(c),
Expand Down Expand Up @@ -1797,8 +1795,7 @@ def test_rejection(self):
c = LWPCookieJar(policy=pol)
c.load(filename, ignore_discard=True)
finally:
try: os.unlink(filename)
except OSError: pass
os_helper.unlink(filename)

self.assertEqual(old, repr(c))

Expand Down Expand Up @@ -1857,8 +1854,7 @@ def save_and_restore(cj, ignore_discard):
DefaultCookiePolicy(rfc2965=True))
new_c.load(ignore_discard=ignore_discard)
finally:
try: os.unlink(filename)
except OSError: pass
os_helper.unlink(filename)
return new_c

new_c = save_and_restore(c, True)
Expand Down