Back to index

python3.2  3.2.2
Public Member Functions
test.test_calendar.CalendarTestCase Class Reference

List of all members.

Public Member Functions

def test_isleap
def test_setfirstweekday
def test_enumerateweekdays
def test_days
def test_months
def test_localecalendars

Detailed Description

Definition at line 207 of file test_calendar.py.


Member Function Documentation

Definition at line 234 of file test_calendar.py.

00234 
00235     def test_days(self):
00236         for attr in "day_name", "day_abbr":
00237             value = getattr(calendar, attr)
00238             self.assertEqual(len(value), 7)
00239             self.assertEqual(len(value[:]), 7)
00240             # ensure they're all unique
00241             self.assertEqual(len(set(value)), 7)
00242             # verify it "acts like a sequence" in two forms of iteration
00243             self.assertEqual(value[::-1], list(reversed(value)))

Here is the call graph for this function:

Definition at line 229 of file test_calendar.py.

00229 
00230     def test_enumerateweekdays(self):
00231         self.assertRaises(IndexError, calendar.day_abbr.__getitem__, -10)
00232         self.assertRaises(IndexError, calendar.day_name.__getitem__, 10)
00233         self.assertEqual(len([d for d in calendar.day_abbr]), 7)

Here is the call graph for this function:

Definition at line 208 of file test_calendar.py.

00208 
00209     def test_isleap(self):
00210         # Make sure that the return is right for a few years, and
00211         # ensure that the return values are 1 or 0, not just true or
00212         # false (see SF bug #485794).  Specific additional tests may
00213         # be appropriate; this tests a single "cycle".
00214         self.assertEqual(calendar.isleap(2000), 1)
00215         self.assertEqual(calendar.isleap(2001), 0)
00216         self.assertEqual(calendar.isleap(2002), 0)
00217         self.assertEqual(calendar.isleap(2003), 0)

Here is the call graph for this function:

Definition at line 255 of file test_calendar.py.

00255 
00256     def test_localecalendars(self):
00257         # ensure that Locale{Text,HTML}Calendar resets the locale properly
00258         # (it is still not thread-safe though)
00259         old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
00260         try:
00261             calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10)
00262         except locale.Error:
00263             # cannot set the system default locale -- skip rest of test
00264             return
00265         calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10)
00266         new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
00267         self.assertEqual(old_october, new_october)
00268 

Here is the call graph for this function:

Definition at line 244 of file test_calendar.py.

00244 
00245     def test_months(self):
00246         for attr in "month_name", "month_abbr":
00247             value = getattr(calendar, attr)
00248             self.assertEqual(len(value), 13)
00249             self.assertEqual(len(value[:]), 13)
00250             self.assertEqual(value[0], "")
00251             # ensure they're all unique
00252             self.assertEqual(len(set(value)), 13)
00253             # verify it "acts like a sequence" in two forms of iteration
00254             self.assertEqual(value[::-1], list(reversed(value)))

Here is the call graph for this function:

Definition at line 218 of file test_calendar.py.

00218 
00219     def test_setfirstweekday(self):
00220         self.assertRaises(TypeError, calendar.setfirstweekday, 'flabber')
00221         self.assertRaises(ValueError, calendar.setfirstweekday, -1)
00222         self.assertRaises(ValueError, calendar.setfirstweekday, 200)
00223         orig = calendar.firstweekday()
00224         calendar.setfirstweekday(calendar.SUNDAY)
00225         self.assertEqual(calendar.firstweekday(), calendar.SUNDAY)
00226         calendar.setfirstweekday(calendar.MONDAY)
00227         self.assertEqual(calendar.firstweekday(), calendar.MONDAY)
00228         calendar.setfirstweekday(orig)

Here is the call graph for this function:


The documentation for this class was generated from the following file: