Merged revisions 83089,87590 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83089 | brett.cannon | 2010-07-23 09:54:14 -0400 (Fri, 23 Jul 2010) | 4 lines Test calendar.monthrange. Closes issue 9342. Thanks John Chandler for the patch. ........ r87590 | r.david.murray | 2010-12-31 14:21:14 -0500 (Fri, 31 Dec 2010) | 4 lines #9361: add some tests for calendar.leapdays Patch by John Chandler. ........
This commit is contained in:
parent
5dd32a2df2
commit
c45d7996db
|
@ -394,12 +394,62 @@ class SundayTestCase(MonthCalendarTestCase):
|
|||
self.check_weeks(1995, 12, (2, 7, 7, 7, 7, 1))
|
||||
|
||||
|
||||
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.
|
||||
with self.assertRaises(calendar.IllegalMonthError):
|
||||
calendar.monthrange(2004, 0)
|
||||
|
||||
def test_thirteenth_month(self):
|
||||
# Tests high invalid boundary case.
|
||||
with self.assertRaises(calendar.IllegalMonthError):
|
||||
calendar.monthrange(2004, 13)
|
||||
|
||||
class LeapdaysTestCase(unittest.TestCase):
|
||||
def test_no_range(self):
|
||||
# test when no range i.e. two identical years as args
|
||||
self.assertEqual(calendar.leapdays(2010,2010), 0)
|
||||
|
||||
def test_no_leapdays(self):
|
||||
# test when no leap years in range
|
||||
self.assertEqual(calendar.leapdays(2010,2011), 0)
|
||||
|
||||
def test_no_leapdays_upper_boundary(self):
|
||||
# test no leap years in range, when upper boundary is a leap year
|
||||
self.assertEqual(calendar.leapdays(2010,2012), 0)
|
||||
|
||||
def test_one_leapday_lower_boundary(self):
|
||||
# test when one leap year in range, lower boundary is leap year
|
||||
self.assertEqual(calendar.leapdays(2012,2013), 1)
|
||||
|
||||
def test_several_leapyears_in_range(self):
|
||||
self.assertEqual(calendar.leapdays(1997,2020), 5)
|
||||
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(
|
||||
OutputTestCase,
|
||||
CalendarTestCase,
|
||||
MondayTestCase,
|
||||
SundayTestCase
|
||||
SundayTestCase,
|
||||
MonthRangeTestCase,
|
||||
LeapdaysTestCase,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue