[Python-checkins] r87590 - python/branches/py3k/Lib/test/test_calendar.py
r.david.murray
python-checkins at python.org
Fri Dec 31 20:21:15 CET 2010
Author: r.david.murray
Date: Fri Dec 31 20:21:14 2010
New Revision: 87590
Log:
#9361: add some tests for calendar.leapdays
Patch by John Chandler.
Modified:
python/branches/py3k/Lib/test/test_calendar.py
Modified: python/branches/py3k/Lib/test/test_calendar.py
==============================================================================
--- python/branches/py3k/Lib/test/test_calendar.py (original)
+++ python/branches/py3k/Lib/test/test_calendar.py Fri Dec 31 20:21:14 2010
@@ -430,6 +430,26 @@
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():
support.run_unittest(
@@ -439,6 +459,7 @@
SundayTestCase,
TimegmTestCase,
MonthRangeTestCase,
+ LeapdaysTestCase,
)
More information about the Python-checkins
mailing list