summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_calendar.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-31 19:21:14 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-31 19:21:14 (GMT)
commit1daaf9e68e52e0c79778e37f395ce686da225385 (patch)
tree7af3b01da14daee6aca48a1c5ff1f5e096925a10 /Lib/test/test_calendar.py
parent7b0e86ef176ac076bf21698a11afaefa871483e2 (diff)
downloadcpython-1daaf9e68e52e0c79778e37f395ce686da225385.zip
cpython-1daaf9e68e52e0c79778e37f395ce686da225385.tar.gz
cpython-1daaf9e68e52e0c79778e37f395ce686da225385.tar.bz2
#9361: add some tests for calendar.leapdays
Patch by John Chandler.
Diffstat (limited to 'Lib/test/test_calendar.py')
-rw-r--r--Lib/test/test_calendar.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 8d7f185..4bd758b 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -430,6 +430,26 @@ class MonthRangeTestCase(unittest.TestCase):
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 @@ def test_main():
SundayTestCase,
TimegmTestCase,
MonthRangeTestCase,
+ LeapdaysTestCase,
)