Commits

Sergey Schetinin  committed 739c73c

fix uses of ok_(x==y) to use eq_(x, y)

  • Participants
  • Parent commits 77d4423

Comments (0)

Files changed (2)

File tests/test_cookies.py

             * input value is an int, should be converted to timedelta and we should
               continue the rest of the process
     """
-    assert '"' not in cookies._quote(cookies.serialize_cookie_date(0))
     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')

File tests/test_datetime_utils.py

 # -*- coding: UTF-8 -*-
 
 import calendar
-import datetime
+from datetime import *
 from rfc822 import formatdate
 from webob import datetime_utils
-from nose.tools import ok_, assert_raises
+from nose.tools import ok_, eq_, assert_raises
 
 def test_parse_date():
     """Testing datetime_utils.parse_date.
         "to parse_date. We should get None but instead we got %s" %\
         ret)
     ret = datetime_utils.parse_date('Mon, 20 Nov 1995 19:12:08 -0500')
-    ok_(ret==datetime.datetime(1995, 11, 21, 0, 12, 8, 
-                               tzinfo=datetime_utils.UTC), 
-        'We passed a valid RFC2822 date but we did not get what we expected.'
-        ' Expected (1995, 11, 21, 0, 12, 8, tzinfo=UTC) but we got %s' % ret)
+    eq_(ret, datetime(1995, 11, 21, 0, 12, 8, tzinfo=datetime_utils.UTC))
     ret = datetime_utils.parse_date('Mon, 20 Nov 1995 19:12:08')
-    ok_(ret==datetime.datetime(1995, 11, 20, 19, 12, 8, 
-                               tzinfo=datetime_utils.UTC), 
-        'We passed a valid RFC2822 date but we did not get what we expected.'
-        ' Expected (1995, 11, 20, 19, 12, 8, tzinfo=UTC) but we got %s' % ret)
+    eq_(ret, datetime(1995, 11, 20, 19, 12, 8, tzinfo=datetime_utils.UTC))
 
 def test_serialize_date():
     """Testing datetime_utils.serialize_date
         * passing an invalid object, should raise ValueError
     """
     ret = datetime_utils.serialize_date(u'Mon, 20 Nov 1995 19:12:08 GMT')
-    ok_(ret=='Mon, 20 Nov 1995 19:12:08 GMT' and type(ret)==str, 
-        'we passed an unicode valid date but we did not get the same value as '
-        'str. Expected: %s, got %s' % ('Mon, 20 Nov 1995 19:12:08 GMT', ret))
-    ok_(formatdate(calendar.timegm((datetime.datetime.now()+datetime.timedelta(1)).\
-                                   timetuple()))==datetime_utils.\
-        serialize_date(datetime.timedelta(1)), 'Passing a timedelta, should '
-       'return now + timedelta')
+    assert type(ret) is (str)
+    eq_(ret, 'Mon, 20 Nov 1995 19:12:08 GMT')
+    dt = formatdate(calendar.timegm((datetime.now()+timedelta(1)).timetuple()))
+    eq_(dt, datetime_utils.serialize_date(timedelta(1)))
     assert_raises(ValueError, datetime_utils.serialize_date, None)
 
 def test_parse_date_delta():
     ok_(datetime_utils.parse_date_delta(None) is None, 'Passing none value, '
         'should return None')
     ret = datetime_utils.parse_date_delta('Mon, 20 Nov 1995 19:12:08 -0500')
-    ok_(ret==datetime.datetime(1995, 11, 21, 0, 12, 8, 
-                               tzinfo=datetime_utils.UTC), 'We passed a '
-        'string so parse_date_delta delegate the result to parse_date')
+    eq_(ret, datetime(1995, 11, 21, 0, 12, 8, tzinfo=datetime_utils.UTC))
 
 def test_serialize_date_delta():
     """Testing datetime_utils.serialize_date_delta
           the task to serialize_date
     """
     ret = datetime_utils.serialize_date_delta(u'Mon, 20 Nov 1995 19:12:08 GMT')
-    ok_(ret=='Mon, 20 Nov 1995 19:12:08 GMT' and type(ret)==str, 
-        'we passed an unicode valid date but we did not get the same value as '
-        'str. Expected: %s, got %s' % ('Mon, 20 Nov 1995 19:12:08 GMT', ret))
+    assert type(ret) is (str)
+    eq_(ret, 'Mon, 20 Nov 1995 19:12:08 GMT')
 
 def test_UTC():
     """Test missing function in _UTC"""
     x = datetime_utils.UTC
-    ok_(x.tzname(datetime.datetime.now())=='UTC')
+    ok_(x.tzname(datetime.now())=='UTC')