Commits

Sergey Schetinin  committed 8796079

fix some tests

  • Participants
  • Parent commits ab8f90d

Comments (0)

Files changed (3)

File tests/test_cookies.py

 from nose.tools import ok_, assert_raises, eq_
 
 def test_cookie():
-    """Testing several missing features of cookies.Cookie.
-    * repr version
-    * ignoring a key-value for Cookie when key == $
+    """
+        Testing several missing features of cookies.Cookie.
+            * repr version
+            * ignoring a key-value for Cookie when key == $
     """
     c = cookies.Cookie() # empty cookie
     eq_(repr(c), '<Cookie: []>')
     # a cookie with one value
-    c = cookies.Cookie('dismiss-top=6') 
+    c = cookies.Cookie('dismiss-top=6')
     eq_(repr(c), "<Cookie: [<Morsel: dismiss-top='6'>]>")
-    c = cookies.Cookie('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: dismiss-top='6'>]>"
     c = cookies.Cookie("dismiss-top=6; CP=null*; "\
                        "PHPSESSID=0a539d42abc001cdc762809248d4beed; a=42")
-    ok_(repr(c), new_c)
-    eq_(c.serialize(), 
+    eq_(repr(c), new_c)
+    eq_(c.serialize(),
         'CP=null*, PHPSESSID=0a539d42abc001cdc762809248d4beed, a=42, '
         'dismiss-top=6')
     # data with key==$
     ok_('$' not in c, 'Key $ should have been ignored')
 
 def test_serialize_cookie_date():
-    """Testing webob.cookies.serialize_cookie_date.
-    Missing scenarios:
-        * input value is an str, should be returned verbatim
-        * input value is an int, should be converted to timedelta and we should
-          continue the rest of the process
+    """
+        Testing webob.cookies.serialize_cookie_date.
+        Missing scenarios:
+            * input value is an str, should be returned verbatim
+            * input value is an int, should be converted to timedelta and we should
+              continue the rest of the process
     """
     ok_(cookies.serialize_cookie_date('Tue, 04-Jan-2011 13:43:50 GMT')==\
         'Tue, 04-Jan-2011 13:43:50 GMT', 'We passed a string, should get the '
         'same one')
-    ok_(cookies.serialize_cookie_date(None)==None, 'We passed None, should '
+    ok_(cookies.serialize_cookie_date(None) is None, 'We passed None, should '
         'get None')
-    ok_(cookies.serialize_cookie_date(timedelta(seconds=10))==\
-        cookies.serialize_cookie_date(10), 'Passing a int to method should '
-        'return the same result as passing a timedelta')
+
+    cdate_delta = cookies.serialize_cookie_date(timedelta(seconds=10))
+    cdate_int = cookies.serialize_cookie_date(10)
+    eq_(cdate_delta, cdate_int,
+        'Passing a int to method should return the same result as passing a timedelta'
+    )
 
 def test_ch_unquote():
     """Inner method _ch_unquote in cookies._unquote is not tested"""

File tests/test_misc.py

     plain = MultiDict(key='\xc3\xb8', fs=fs)
     ua = UnicodeMultiDict(multi=plain, encoding='utf-8')
     eq(ua.getall('key'), [u'\xf8'])
-    eq(ua.getall('fs'), [cgi.FieldStorage(None, u'\xf8', [])])
+    eq(repr(ua.getall('fs')), "[FieldStorage(None, u'\\xf8', [])]")
     ub = UnicodeMultiDict(multi=ua, encoding='utf-8')
     eq(ub.getall('key'), [u'\xf8'])
-    eq(ub.getall('fs'), [cgi.FieldStorage(None, u'\xf8', [])])
+    eq(repr(ub.getall('fs')), "[FieldStorage(None, u'\\xf8', [])]")

File webob/cookies.py

-import string, re
-import time
+import re, time, string
 from datetime import datetime, date, timedelta
 
 __all__ = ['Cookie']