summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-12-20 01:31:27 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-12-20 01:31:27 (GMT)
commit328fff72149a896141209b57b577b4dc57ea5d90 (patch)
treed78d51ecd4cfa4cb574794b2e241d193035e4588 /Lib
parentd0e2926d2a10ff3414b3d9177034728c1a074cd1 (diff)
downloadcpython-328fff72149a896141209b57b577b4dc57ea5d90.zip
cpython-328fff72149a896141209b57b577b4dc57ea5d90.tar.gz
cpython-328fff72149a896141209b57b577b4dc57ea5d90.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_datetime.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index cf6bd92..2d7922f 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -469,20 +469,27 @@ class TestDate(unittest.TestCase):
self.assertEqual(fromord.second, 0)
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):
+ # 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)
- # 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)
+ 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.
dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]