[Python-checkins] r83089 - in python/branches/py3k: Lib/test/test_calendar.py Misc/ACKS

brett.cannon python-checkins at python.org
Fri Jul 23 15:54:15 CEST 2010


Author: brett.cannon
Date: Fri Jul 23 15:54:14 2010
New Revision: 83089

Log:
Test calendar.monthrange.

Closes issue 9342. Thanks John Chandler for the patch.


Modified:
   python/branches/py3k/Lib/test/test_calendar.py
   python/branches/py3k/Misc/ACKS

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 Jul 23 15:54:14 2010
@@ -389,6 +389,34 @@
             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.
+        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)
+
+
 def test_main():
     support.run_unittest(
         OutputTestCase,
@@ -396,6 +424,7 @@
         MondayTestCase,
         SundayTestCase,
         TimegmTestCase,
+        MonthRangeTestCase,
     )
 
 

Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS	(original)
+++ python/branches/py3k/Misc/ACKS	Fri Jul 23 15:54:14 2010
@@ -129,6 +129,7 @@
 Per Cederqvist
 Octavian Cerna
 Pascal Chambon
+John Chandler
 Hye-Shik Chang
 Jeffrey Chang
 Mitch Chapman


More information about the Python-checkins mailing list