[Zope-Checkins] CVS: Packages/DateTime/tests -
testDateTime.py:1.21.12.2
Evan Simpson
cvs-admin at zope.org
Thu Nov 20 12:12:20 EST 2003
Update of /cvs-repository/Packages/DateTime/tests
In directory cvs.zope.org:/tmp/cvs-serv10146/lib/python/DateTime/tests
Modified Files:
Tag: Zope-2_7-branch
testDateTime.py
Log Message:
Mostly fixed Collector #1129. Badly formed ISO8601 dates are rejected,
except that 'Z' is still allowed in front of a '+/-HH:MM' timezone. I
left that in since it was used elsewhere in the code, and was probably
harmless, whereas the other parse problems caused dates like "2003-2-5"
to be accepted as valid and silently converted into "2003-01-01".
Also re-exposed the DateTime-specific exceptions as attributes of the
DateTime class. During their recent converted from strings to classes,
they were removed.
=== Packages/DateTime/tests/testDateTime.py 1.21.12.1 => 1.21.12.2 ===
--- Packages/DateTime/tests/testDateTime.py:1.21.12.1 Mon Jul 21 12:35:25 2003
+++ Packages/DateTime/tests/testDateTime.py Thu Nov 20 12:12:19 2003
@@ -257,9 +257,17 @@
isoDt = DateTime('2002-05-02T08:00:00Z')
self.assertEqual( ref0, isoDt)
- isoDt = DateTime('2002-05-02T08:00:00Z-04:00')
+ isoDt = DateTime('2002-05-02T08:00:00-04:00')
self.assertEqual( ref1, isoDt)
+ dgood = '2002-05-02'
+ tgood = 'T08:00:00-04:00'
+ for dbad in '2002-5-2', '2002-10-2', '2002-2-10', '02-2-10':
+ self.assertRaises(DateTime.SyntaxError, DateTime, dbad)
+ self.assertRaises(DateTime.SyntaxError, DateTime, dbad + tgood)
+ for tbad in '08:00', 'T8:00': #, 'T08:00Z-04:00':
+ self.assertRaises(DateTime.SyntaxError, DateTime, dgood + tbad)
+
def testJulianWeek(self):
""" check JulianDayWeek function """
@@ -279,13 +287,13 @@
def testRFC822(self):
'''rfc822 conversion'''
- dt = DateTime('2002-05-02T08:00:00Z+00:00')
+ dt = DateTime('2002-05-02T08:00:00+00:00')
self.assertEqual(dt.rfc822(), 'Thu, 02 May 2002 08:00:00 +0000')
- dt = DateTime('2002-05-02T08:00:00Z+02:00')
+ dt = DateTime('2002-05-02T08:00:00+02:00')
self.assertEqual(dt.rfc822(), 'Thu, 02 May 2002 08:00:00 +0200')
- dt = DateTime('2002-05-02T08:00:00Z-02:00')
+ dt = DateTime('2002-05-02T08:00:00-02:00')
self.assertEqual(dt.rfc822(), 'Thu, 02 May 2002 08:00:00 -0200')
# Checking that conversion from local time is working.
More information about the Zope-Checkins
mailing list