From ab069a4a857a182a87fa9ad9b3c893b48ce16ce8 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Sun, 27 Apr 2014 13:28:25 -0700 Subject: [PATCH] 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. --- Lib/test/test_calendar.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 39b47e6fa39ca8..b7cbe740119cad 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -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='')