Commit d41ce08c authored by Jeffrey Shell's avatar Jeffrey Shell

Applied patch suggested by Chris Withers (Collector #2457) to clarify

some failures that are still occuring.  Moved in from the
Zope-2_4-branch.
parent de8de921
......@@ -5,6 +5,20 @@
import unittest
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 @@ class DateTimeTests (unittest.TestCase):
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 @@ class DateTimeTests (unittest.TestCase):
'''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 @@ class DateTimeTests (unittest.TestCase):
'''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():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment