Skip to content

Commit ab069a4

Browse files
jesstessbxsx
authored andcommitted
gh-57539: Add tests for LocaleTextCalendar.formatweekday
This patch has already been applied to `main` branch (via gh-93468), but with wrong copyright. After merging this commit to `main`, git `Author` metadata will be updated to the original author.
1 parent b850c92 commit ab069a4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_calendar.py

+10
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,16 @@ def test_locale_calendars(self):
605605
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
606606
self.assertEqual(old_october, new_october)
607607

608+
def test_locale_calendar_formatweekday(self):
609+
# formatweekday uses different day names based on the available width.
610+
cal = calendar.LocaleTextCalendar(locale='en_US')
611+
# For short widths, a centered, abbreviated name is used.
612+
self.assertEqual(cal.formatweekday(0, 5), " Mon ")
613+
# For really short widths, even the abbreviated name is truncated.
614+
self.assertEqual(cal.formatweekday(0, 2), "Mo")
615+
# For long widths, the full day name is used.
616+
self.assertEqual(cal.formatweekday(0, 10), " Monday ")
617+
608618
def test_locale_html_calendar_custom_css_class_month_name(self):
609619
try:
610620
cal = calendar.LocaleHTMLCalendar(locale='')

0 commit comments

Comments
 (0)