[Python-checkins] python/dist/src/Lib/test test_datetime.py,1.2,1.3

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 19 Dec 2002 17:31:29 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv17490/python/Lib/test

Modified Files:
	test_datetime.py 
Log Message:
format_utcoffset():  The natural type of the buflen arg is size_t, so
used that.

wrap_strftime():  Removed the most irritating uses of buf.

TestDate.test_ordinal_conversions():  The C implementation is fast enough
that we can afford to check the endpoints of every year.  Also added
tm_yday tests at the endpoints.


Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_datetime.py	16 Dec 2002 21:12:37 -0000	1.2
--- test_datetime.py	20 Dec 2002 01:31:26 -0000	1.3
***************
*** 470,487 ****
                  self.assertEqual(fromord.microsecond, 0)
  
!         # Check first and last days of year spottily across the whole
!         # range of years supported.
!         for year in xrange(MINYEAR, MAXYEAR+1, 7):
              # Verify (year, 1, 1) -> ordinal -> y, m, d is identity.
              d = self.theclass(year, 1, 1)
              n = d.toordinal()
              d2 = self.theclass.fromordinal(n)
              self.assertEqual(d, d2)
!             # Verify that moving back a day gets to the end of year-1.
!             if year > 1:
!                 d = self.theclass.fromordinal(n-1)
!                 d2 = self.theclass(year-1, 12, 31)
!                 self.assertEqual(d, d2)
!                 self.assertEqual(d2.toordinal(), n-1)
  
          # Test every day in a leap-year and a non-leap year.
--- 470,494 ----
                  self.assertEqual(fromord.microsecond, 0)
  
!         # Check first and last days of year across the whole range of years
!         # supported.
!         ordinal = 1
!         for year in xrange(MINYEAR, MAXYEAR+1):
              # Verify (year, 1, 1) -> ordinal -> y, m, d is identity.
              d = self.theclass(year, 1, 1)
              n = d.toordinal()
+             self.assertEqual(ordinal, n)
              d2 = self.theclass.fromordinal(n)
              self.assertEqual(d, d2)
!             self.assertEqual(d.timetuple().tm_yday, 1)
!             # Same for (year, 12, 31).
!             isleap = year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
!             days_in_year = 365 + isleap
!             d = self.theclass(year, 12, 31)
!             n = d.toordinal()
!             self.assertEqual(n, ordinal + days_in_year - 1)
!             self.assertEqual(d.timetuple().tm_yday, days_in_year)
!             d2 = self.theclass.fromordinal(n)
!             self.assertEqual(d, d2)
!             ordinal += days_in_year
  
          # Test every day in a leap-year and a non-leap year.