diff options
author | Fred Drake <fdrake@acm.org> | 2001-12-12 05:38:08 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-12-12 05:38:08 (GMT) |
commit | d077ca1e7c0303af8863bbd65423c23354389353 (patch) | |
tree | 499d65c9909ec78fee06dd995741c8f8eb0fd5b5 | |
parent | f0953b9dff9a0cc08b6dcfe206047c0490e1d38a (diff) | |
download | cpython-d077ca1e7c0303af8863bbd65423c23354389353.zip cpython-d077ca1e7c0303af8863bbd65423c23354389353.tar.gz cpython-d077ca1e7c0303af8863bbd65423c23354389353.tar.bz2 |
Very small test suite for the calendar module, mostly to check a constraint
on the return values from isleap(). Also checks firstweekday() and
setfirstweekday().
-rw-r--r-- | Lib/test/test_calendar.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py new file mode 100644 index 0000000..1807a59 --- /dev/null +++ b/Lib/test/test_calendar.py @@ -0,0 +1,34 @@ +import calendar +import unittest + +from test_support import run_unittest + + +class CalendarTestCase(unittest.TestCase): + def test_isleap(self): + # Make sure that the return is right for a few years, and + # ensure that the return values are 1 or 0, not just true or + # false (see SF bug #485794). Specific additional tests may + # be appropriate; this tests a single "cycle". + self.assertEqual(calendar.isleap(2000), 1) + self.assertEqual(calendar.isleap(2001), 0) + self.assertEqual(calendar.isleap(2002), 0) + self.assertEqual(calendar.isleap(2003), 0) + + def test_setfirstweekday(self): + self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') + self.assertRaises(ValueError, calendar.setfirstweekday, -1) + self.assertRaises(ValueError, calendar.setfirstweekday, 200) + orig = calendar.firstweekday() + calendar.setfirstweekday(calendar.SUNDAY) + self.assertEqual(calendar.firstweekday(), calendar.SUNDAY) + calendar.setfirstweekday(calendar.MONDAY) + self.assertEqual(calendar.firstweekday(), calendar.MONDAY) + calendar.setfirstweekday(orig) + + +def test_main(): + run_unittest(CalendarTestCase) + +if __name__ == "__main__": + test_main() |