Skip to content

Commit

Permalink
pythongh-57539: Add tests for LocaleTextCalendar.formatweekday
Browse files Browse the repository at this point in the history
This patch has already been applied to `main` branch (via pythongh-93468), but
with wrong copyright. After merging this commit to `main`, git `Author`
metadata will be updated to the original author.
  • Loading branch information
jesstess authored and bxsx committed Jun 9, 2022
1 parent b850c92 commit ab069a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Lib/test/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,16 @@ def test_locale_calendars(self):
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
self.assertEqual(old_october, new_october)

def test_locale_calendar_formatweekday(self):
# formatweekday uses different day names based on the available width.
cal = calendar.LocaleTextCalendar(locale='en_US')
# For short widths, a centered, abbreviated name is used.
self.assertEqual(cal.formatweekday(0, 5), " Mon ")
# For really short widths, even the abbreviated name is truncated.
self.assertEqual(cal.formatweekday(0, 2), "Mo")
# For long widths, the full day name is used.
self.assertEqual(cal.formatweekday(0, 10), " Monday ")

def test_locale_html_calendar_custom_css_class_month_name(self):
try:
cal = calendar.LocaleHTMLCalendar(locale='')
Expand Down

0 comments on commit ab069a4

Please sign in to comment.