diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2005-03-03 10:48:12 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2005-03-03 10:48:12 (GMT) |
commit | 4ea3eade518c6a48b0708736442deefe669fe287 (patch) | |
tree | b1fe49fc925e2c4cbb51793042c182582fe8d87f /Lib/test/test_cookielib.py | |
parent | 9b62b3907056bedc83e7a2198eec722c84d7c473 (diff) | |
download | cpython-4ea3eade518c6a48b0708736442deefe669fe287.zip cpython-4ea3eade518c6a48b0708736442deefe669fe287.tar.gz cpython-4ea3eade518c6a48b0708736442deefe669fe287.tar.bz2 |
Patch #1117339: Add cookielib special name tests.
Backported to 2.4.
Diffstat (limited to 'Lib/test/test_cookielib.py')
-rw-r--r-- | Lib/test/test_cookielib.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_cookielib.py index 72c9fc8..679e3aa 100644 --- a/Lib/test/test_cookielib.py +++ b/Lib/test/test_cookielib.py @@ -103,13 +103,23 @@ class HeaderTests(TestCase): from cookielib import parse_ns_headers # quotes should be stripped - expected = [[('expires', 2209069412L), ('version', '0')]] + expected = [[('foo', 'bar'), ('expires', 2209069412L), ('version', '0')]] for hdr in [ - 'expires=01 Jan 2040 22:23:32 GMT', - 'expires="01 Jan 2040 22:23:32 GMT"', + 'foo=bar; expires=01 Jan 2040 22:23:32 GMT', + 'foo=bar; expires="01 Jan 2040 22:23:32 GMT"', ]: self.assertEquals(parse_ns_headers([hdr]), expected) + def test_parse_ns_headers_special_names(self): + # names such as 'expires' are not special in first name=value pair + # of Set-Cookie: header + from cookielib import parse_ns_headers + + # Cookie with name 'expires' + hdr = 'expires=01 Jan 2040 22:23:32 GMT' + expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]] + self.assertEquals(parse_ns_headers([hdr]), expected) + def test_join_header_words(self): from cookielib import join_header_words @@ -370,6 +380,19 @@ class CookieTests(TestCase): self.assert_(foo.expires is None) self.assert_(spam.expires is None) + def test_ns_parser_special_names(self): + # names such as 'expires' are not special in first name=value pair + # of Set-Cookie: header + from cookielib import CookieJar + + c = CookieJar() + interact_netscape(c, "http://www.acme.com/", 'expires=eggs') + interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs') + + cookies = c._cookies["www.acme.com"]["/"] + self.assert_('expires' in cookies) + self.assert_('version' in cookies) + def test_expires(self): from cookielib import time2netscape, CookieJar |