Message121776
Quick hack alternative test. It would look nicer if the test used the datetime module, but I'm not sure that would be appropriate.
def test_dayofyear(self):
"""Test for the calendar.dayofyear() function, which computes the
integer between 1 and 366 (inclusive) representing the specified day in
the specified month of the specified year.
"""
for expected_total, year in (366, 2008), (365, 2010):
expected_day_of_year = 1
for month in range(1, 13):
lastDay = calendar.mdays[month]
if year == 2008 and month == 2:
lastDay = 29
for day in range(1, lastDay + 1):
day_of_year = calendar.dayofyear(year, month, day)
self.assertEqual(expected_day_of_year, day_of_year)
# The computed day of the year must be between 1 and 366.
self.assertGreaterEqual(day_of_year, 1)
self.assertLessEqual(day_of_year, 366)
expected_day_of_year += 1
self.assertEqual(expected_day_of_year - 1, expected_total) |
|
Date |
User |
Action |
Args |
2010-11-20 21:07:03 | ark3 | set | recipients:
+ ark3, jfinkels, JJeffries |
2010-11-20 21:07:02 | ark3 | set | messageid: <1290287222.9.0.718510011893.issue9909@psf.upfronthosting.co.za> |
2010-11-20 21:07:01 | ark3 | link | issue9909 messages |
2010-11-20 21:07:01 | ark3 | create | |
|