Index: Lib/test/test_calendar.py =================================================================== --- Lib/test/test_calendar.py (revision 83065) +++ Lib/test/test_calendar.py (working copy) @@ -389,6 +389,32 @@ tuple = time.gmtime(secs) self.assertEqual(secs, calendar.timegm(tuple)) +class MonthRangeTestCase(unittest.TestCase): + def test_january(self): + # tests valid lower boundary case + self.assertEqual(calendar.monthrange(2004,1), (3,31)) + + def test_february_leap(self): + # tests February during leap year + self.assertEqual(calendar.monthrange(2004,2), (6,29)) + + def test_february_nonleap(self): + # tests February in non-leap year + self.assertEqual(calendar.monthrange(2010,2), (0,28)) + + def test_december(self): + # tests valid upper boundary case + self.assertEqual(calendar.monthrange(2004,12), (2,31)) + + def test_zeroth_month(self): + # tests low invalid boundary case + self.assertRaises(calendar.IllegalMonthError, calendar.monthrange, 2004, 0) + + def test_thirteenth_month(self): + # tests high invalid boundary case + self.assertRaises(calendar.IllegalMonthError, calendar.monthrange, 2004, 13) + + def test_main(): support.run_unittest( OutputTestCase, @@ -396,6 +422,7 @@ MondayTestCase, SundayTestCase, TimegmTestCase, + MonthRangeTestCase, )