Skip to content

Commit 258342e

Browse files
committed
Update test_calendar.py from CPython v3.12.0
1 parent 69e8e4b commit 258342e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Lib/test/test_calendar.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import datetime
1010
import os
11+
import warnings
1112

1213
# From https://en.wikipedia.org/wiki/Leap_year_starting_on_Saturday
1314
result_0_02_text = """\
@@ -490,6 +491,14 @@ def test_format(self):
490491
self.assertEqual(out.getvalue().strip(), "1 2 3")
491492

492493
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+
493502
def test_isleap(self):
494503
# Make sure that the return is right for a few years, and
495504
# ensure that the return values are 1 or 0, not just true or
@@ -568,11 +577,15 @@ def test_locale_calendar_formatweekday(self):
568577
try:
569578
# formatweekday uses different day names based on the available width.
570579
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")
571583
# For short widths, a centered, abbreviated name is used.
584+
self.assertEqual(cal.formatweekday(0, 3), "Mon")
572585
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 ")
575587
# For long widths, the full day name is used.
588+
self.assertEqual(cal.formatweekday(0, 9), " Monday ")
576589
self.assertEqual(cal.formatweekday(0, 10), " Monday ")
577590
except locale.Error:
578591
raise unittest.SkipTest('cannot set the en_US locale')

0 commit comments

Comments
 (0)