Patch #1117454: Remove code to special-case cookies without values
in LWPCookieJar. Backported to 2.4.
diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py
index 679e3aa..7828326 100644
--- a/Lib/test/test_cookielib.py
+++ b/Lib/test/test_cookielib.py
@@ -231,6 +231,24 @@
return cookie_hdr
+class FileCookieJarTests(TestCase):
+ def test_lwp_valueless_cookie(self):
+ # cookies with no value should be saved and loaded consistently
+ from cookielib import LWPCookieJar
+ filename = test_support.TESTFN
+ c = LWPCookieJar()
+ interact_netscape(c, "http://www.acme.com/", 'boo')
+ self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
+ try:
+ c.save(filename, ignore_discard=True)
+ c = LWPCookieJar()
+ c.load(filename, ignore_discard=True)
+ finally:
+ try: os.unlink(filename)
+ except OSError: pass
+ self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
+
+
class CookieTests(TestCase):
# XXX
# Get rid of string comparisons where not actually testing str / repr.
@@ -1636,6 +1654,7 @@
DateTimeTests,
HeaderTests,
CookieTests,
+ FileCookieJarTests,
LWPCookieTests,
)