[Python-checkins] CVS: python/nondist/sandbox/datetime test_datetime.py,1.20,1.21
Tim Peters
tim_one@users.sourceforge.net
Sun, 03 Mar 2002 17:15:01 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory usw-pr-cvs1:/tmp/cvs-serv28300
Modified Files:
test_datetime.py
Log Message:
test_ordinal_conversions(): Exhaustively test ordinal<->date for every
day in a leap year, and in a non leap year.
Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_datetime.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** test_datetime.py 3 Mar 2002 23:16:21 -0000 1.20
--- test_datetime.py 4 Mar 2002 01:14:59 -0000 1.21
***************
*** 64,67 ****
--- 64,79 ----
self.assertEqual(_ymd2ord(year-1, 12, 31), n-1)
+ # Test every day in a leap-year and a non-leap year.
+ dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+ for year, isleap in (2000, 1), (2002, 0):
+ n = _ymd2ord(year, 1, 1)
+ for month, maxday in zip(range(1, 13), dim):
+ if month == 2 and isleap:
+ maxday += 1
+ for day in range(1, maxday+1):
+ self.assertEqual((year, month, day), _ord2ymd(n))
+ self.assertEqual(n, _ymd2ord(year, month, day))
+ n += 1
+
def test_bad_constructor_arguments(self):
from datetime import MINYEAR, MAXYEAR