[Zope-Checkins] CVS: Zope/lib/python/DateTime/tests - testDateTime.py:1.2.18.1

Shane Hathaway shane@digicool.com
Thu, 9 Aug 2001 13:34:01 -0400


Update of /cvs-repository/Zope/lib/python/DateTime/tests
In directory cvs.zope.org:/tmp/cvs-serv29115/lib/python/DateTime/tests

Modified Files:
      Tag: NR-branch
	testDateTime.py 
Log Message:
Sync NR-branch with trunk.  Sorry about so many checkin messages...


=== Zope/lib/python/DateTime/tests/testDateTime.py 1.2 => 1.2.18.1 ===
 from DateTime import DateTime
 import string
+import math
+
+def _compare(dt1, dt2):
+    '''Compares the internal representation of dt1 with
+    the representation in dt2.  Allows sub-millisecond variations.
+    Primarily for testing.'''
+    assert dt1.millis() == dt2.millis(), \
+           '%s != %s' % (dt1.millis(),dt2.millis())
+    assert math.floor(dt1._t * 1000.0) == \
+               math.floor(dt2._t * 1000.0)
+    assert math.floor(dt1._d * 86400000.0) == \
+               math.floor(dt2._d * 86400000.0)
+    assert math.floor(dt1.time * 86400000.0) == \
+               math.floor(dt2.time * 86400000.0)
 
 class DateTimeTests (unittest.TestCase):
 
@@ -31,15 +45,16 @@
     def testConstructor3(self):
         '''Constructor from date/time string'''
         dt = DateTime()
-        dt1 = DateTime('%d/%d/%d %d:%d:%f %s' % (
+        dt1s = '%d/%d/%d %d:%d:%f %s' % (
             dt.year(),
             dt.month(),
             dt.day(),
             dt.hour(),
             dt.minute(),
             dt.second(),
-            dt.timezone()))
-        assert dt.debugCompare(dt1), (dt, dt1)
+            dt.timezone())
+        dt1 = DateTime(dt1s)
+        _compare(dt, dt1)
 
     def testConstructor4(self):
         '''Constructor from time float'''
@@ -57,7 +72,7 @@
         '''Constructor from year and julian date'''
         dt = DateTime('1980/1/5 12:00:00.050 pm')
         dt1 = DateTime(1980, 5.500000578705)
-        assert dt.debugCompare(dt1), (dt, dt1)
+        _compare(dt, dt1)
 
     def testConstructor7(self):
         '''Constructor from parts'''
@@ -134,7 +149,7 @@
         '''Comparison of a Y10K date and a Y2K date'''
         dt = DateTime('10213/09/21')
         dt1 = DateTime(2000, 1, 1)
-        assert dt - dt1 == 3000000.0, (dt, dt1)
+        assert dt - dt1 == 3000000.0, (dt - dt1)
 
 
 def test_suite():