[Python-checkins] python/dist/src/Lib/test test_cookielib.py, 1.1, 1.1.4.1

loewis at users.sourceforge.net loewis at users.sourceforge.net
Thu Mar 3 11:47:40 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4377/Lib/test

Modified Files:
      Tag: release24-maint
	test_cookielib.py 
Log Message:
Patch #1117339: Add cookielib special name tests.


Index: test_cookielib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- test_cookielib.py	31 May 2004 18:22:40 -0000	1.1
+++ test_cookielib.py	3 Mar 2005 10:47:38 -0000	1.1.4.1
@@ -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