def test_output_textcalendar(self):
self.assertEqual(
calendar.TextCalendar().formatyear(2004).strip(),
result_2004_text.strip()
)
python类TextCalendar()的实例源码
def test_output_textcalendar(self):
self.assertEqual(
calendar.TextCalendar().formatyear(2004).strip(),
result_2004_text.strip()
)
def test_formatweekheader_short(self):
self.assertEqual(
calendar.TextCalendar().formatweekheader(2),
'Mo Tu We Th Fr Sa Su'
)
def test_formatweekheader_long(self):
self.assertEqual(
calendar.TextCalendar().formatweekheader(9),
' Monday Tuesday Wednesday Thursday '
' Friday Saturday Sunday '
)
def test_formatmonth(self):
self.assertEqual(
calendar.TextCalendar().formatmonth(2004, 1).strip(),
result_2004_01_text.strip()
)
def test_prweek(self):
with support.captured_stdout() as out:
week = [(1,0), (2,1), (3,2), (4,3), (5,4), (6,5), (7,6)]
calendar.TextCalendar().prweek(week, 1)
self.assertEqual(out.getvalue().strip(), "1 2 3 4 5 6 7")
def test_pryear(self):
with support.captured_stdout() as out:
calendar.TextCalendar().pryear(2004)
self.assertEqual(out.getvalue().strip(), result_2004_text.strip())