Commits

Sergey Schetinin committed 376707d

edit cookie tests

  • Participants
  • Parent commits 4c4bf44

Comments (0)

Files changed (3)

 doctests = ['test_dec', 'test_request', 'test_response']
 doctests += map('../docs/'.__add__, ['do-it-yourself', 'file-example', 'index', 'reference'])
 map(suite.add_doctest, doctests)
-map(suite.add_nosetest, ['test_request', 'test_response', 'test_multidict', 'test_misc'])
+suite.add_unittest('test_multidict')
+map(suite.add_nosetest, [
+    'test_request', 'test_response', 'test_headers',
+    'test_cookies', 'test_exc',
+    'test_misc', 'test_datetime_utils',
+])
 
 
 if __name__ == '__main__':
     suite.run_text()
+
+

tests/test_cookies.py

     eq_(repr(c), "<Cookie: [<Morsel: dismiss-top='6'>]>")
     c = cookies.Cookie('dismiss-top=6;')
     eq_(repr(c), "<Cookie: [<Morsel: dismiss-top='6'>]>")
-    # more complex cookie
-    new_c = "<Cookie: [<Morsel: a='42'>, <Morsel: CP='null*'>, "\
-    "<Morsel: PHPSESSID='0a539d42abc001cdc762809248d4beed'>, "\
-    "<Morsel: dismiss-top='6'>]>"
-    c = cookies.Cookie("dismiss-top=6; CP=null*; "\
-                       "PHPSESSID=0a539d42abc001cdc762809248d4beed; a=42")
-    eq_(repr(c), new_c)
+    # more complex cookie, (also mixing commas and semicolons)
+    c = cookies.Cookie("dismiss-top=6; CP=null*, "\
+                       "PHPSESSID=0a539d42abc001cdc762809248d4beed, a=42")
+    c_dict = dict((k,v.value) for k,v in c.items())
+    eq_(c_dict, {'a': '42',
+        'CP': 'null*',
+        'PHPSESSID': '0a539d42abc001cdc762809248d4beed',
+        'dismiss-top': '6'
+    })
     eq_(c.serialize(),
         'CP=null*, PHPSESSID=0a539d42abc001cdc762809248d4beed, a=42, '
         'dismiss-top=6')
     c = cookies.Cookie('dismiss-top=6; CP=null*; $version=42; a=42')
     assert '$version' not in c
     c = cookies.Cookie('$reserved=42; a=$42')
-    eq(c.keys(), ['a'])
+    eq_(c.keys(), ['a'])
 
 def test_serialize_cookie_date():
     """
 #
 
 _re_quoted = r'"(?:[^\"]|\.)*"'  # any doublequoted string
-_legal_special_chars = "~!@#$%^&*()_+=-`.?|:/(){}<>',"
+_legal_special_chars = "~!@#$%^&*()_+=-`.?|:/(){}<>'"
 _re_legal_char  = r"[\w\d%s]" % ''.join(map(r'\%s'.__mod__, _legal_special_chars))
 _re_expires_val = r"\w{3},\s[\w\d-]{9,11}\s[\d:]{8}\sGMT"
 _rx_cookie = re.compile(