[Python-checkins] python/dist/src/Lib/test test_cookielib.py, 1.1,
1.2
loewis at users.sourceforge.net
loewis at users.sourceforge.net
Thu Mar 3 11:48:15 CET 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4491/Lib/test
Modified Files:
test_cookielib.py
Log Message:
Patch #1117339: Add cookielib special name tests.
Backported to 2.4.
Index: test_cookielib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_cookielib.py 31 May 2004 18:22:40 -0000 1.1
+++ test_cookielib.py 3 Mar 2005 10:48:12 -0000 1.2
@@ -103,13 +103,23 @@
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 @@
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
More information about the Python-checkins
mailing list