gh-57539: Increase calendar test coverage (GH-93468) (GH-93564)

(cherry picked from commit f0d0be3493)

Co-authored-by: Sean Fleming
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-06-07 03:21:04 -07:00 committed by GitHub
parent 2a24421054
commit faf0cf7ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -564,6 +564,19 @@ class CalendarTestCase(unittest.TestCase):
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10) new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
self.assertEqual(old_october, new_october) self.assertEqual(old_october, new_october)
def test_locale_calendar_formatweekday(self):
try:
# 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 ")
except locale.Error:
raise unittest.SkipTest('cannot set the en_US locale')
def test_locale_html_calendar_custom_css_class_month_name(self): def test_locale_html_calendar_custom_css_class_month_name(self):
try: try:
cal = calendar.LocaleHTMLCalendar(locale='') cal = calendar.LocaleHTMLCalendar(locale='')

View File

@ -548,6 +548,7 @@ Nils Fischbeck
Frederik Fix Frederik Fix
Tom Flanagan Tom Flanagan
Matt Fleming Matt Fleming
Sean Fleming
Hernán Martínez Foffani Hernán Martínez Foffani
Benjamin Fogle Benjamin Fogle
Artem Fokin Artem Fokin

View File

@ -0,0 +1 @@
Increase calendar test coverage for :meth:`calendar.LocaleTextCalendar.formatweekday`.