blob: 1807a59ad369c3fdfc08665cd6f81c2dc0f5733f [file] [log] [blame]
Fred Draked077ca12001-12-12 05:38:08 +00001import calendar
2import unittest
3
4from test_support import run_unittest
5
6
7class CalendarTestCase(unittest.TestCase):
8 def test_isleap(self):
9 # Make sure that the return is right for a few years, and
10 # ensure that the return values are 1 or 0, not just true or
11 # false (see SF bug #485794). Specific additional tests may
12 # be appropriate; this tests a single "cycle".
13 self.assertEqual(calendar.isleap(2000), 1)
14 self.assertEqual(calendar.isleap(2001), 0)
15 self.assertEqual(calendar.isleap(2002), 0)
16 self.assertEqual(calendar.isleap(2003), 0)
17
18 def test_setfirstweekday(self):
19 self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber')
20 self.assertRaises(ValueError, calendar.setfirstweekday, -1)
21 self.assertRaises(ValueError, calendar.setfirstweekday, 200)
22 orig = calendar.firstweekday()
23 calendar.setfirstweekday(calendar.SUNDAY)
24 self.assertEqual(calendar.firstweekday(), calendar.SUNDAY)
25 calendar.setfirstweekday(calendar.MONDAY)
26 self.assertEqual(calendar.firstweekday(), calendar.MONDAY)
27 calendar.setfirstweekday(orig)
28
29
30def test_main():
31 run_unittest(CalendarTestCase)
32
33if __name__ == "__main__":
34 test_main()