|
8 | 8 | import sys
|
9 | 9 | import datetime
|
10 | 10 | import os
|
| 11 | +import warnings |
11 | 12 |
|
12 | 13 | # From https://en.wikipedia.org/wiki/Leap_year_starting_on_Saturday
|
13 | 14 | result_0_02_text = """\
|
@@ -490,6 +491,14 @@ def test_format(self):
|
490 | 491 | self.assertEqual(out.getvalue().strip(), "1 2 3")
|
491 | 492 |
|
492 | 493 | class CalendarTestCase(unittest.TestCase):
|
| 494 | + |
| 495 | + def test_deprecation_warning(self): |
| 496 | + with self.assertWarnsRegex( |
| 497 | + DeprecationWarning, |
| 498 | + "The 'January' attribute is deprecated, use 'JANUARY' instead" |
| 499 | + ): |
| 500 | + calendar.January |
| 501 | + |
493 | 502 | def test_isleap(self):
|
494 | 503 | # Make sure that the return is right for a few years, and
|
495 | 504 | # ensure that the return values are 1 or 0, not just true or
|
@@ -568,11 +577,15 @@ def test_locale_calendar_formatweekday(self):
|
568 | 577 | try:
|
569 | 578 | # formatweekday uses different day names based on the available width.
|
570 | 579 | cal = calendar.LocaleTextCalendar(locale='en_US')
|
| 580 | + # For really short widths, the abbreviated name is truncated. |
| 581 | + self.assertEqual(cal.formatweekday(0, 1), "M") |
| 582 | + self.assertEqual(cal.formatweekday(0, 2), "Mo") |
571 | 583 | # For short widths, a centered, abbreviated name is used.
|
| 584 | + self.assertEqual(cal.formatweekday(0, 3), "Mon") |
572 | 585 | self.assertEqual(cal.formatweekday(0, 5), " Mon ")
|
573 |
| - # For really short widths, even the abbreviated name is truncated. |
574 |
| - self.assertEqual(cal.formatweekday(0, 2), "Mo") |
| 586 | + self.assertEqual(cal.formatweekday(0, 8), " Mon ") |
575 | 587 | # For long widths, the full day name is used.
|
| 588 | + self.assertEqual(cal.formatweekday(0, 9), " Monday ") |
576 | 589 | self.assertEqual(cal.formatweekday(0, 10), " Monday ")
|
577 | 590 | except locale.Error:
|
578 | 591 | raise unittest.SkipTest('cannot set the en_US locale')
|
|
0 commit comments