Skip to content

Commit faf0cf7

Browse files
miss-islingtonAA-Turnerambvhugovk
authored
gh-57539: Increase calendar test coverage (GH-93468) (GH-93564)
(cherry picked from commit f0d0be3) 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>
1 parent 2a24421 commit faf0cf7

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Lib/test/test_calendar.py

+13
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,19 @@ def test_locale_calendars(self):
564564
new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
565565
self.assertEqual(old_october, new_october)
566566

567+
def test_locale_calendar_formatweekday(self):
568+
try:
569+
# formatweekday uses different day names based on the available width.
570+
cal = calendar.LocaleTextCalendar(locale='en_US')
571+
# For short widths, a centered, abbreviated name is used.
572+
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")
575+
# For long widths, the full day name is used.
576+
self.assertEqual(cal.formatweekday(0, 10), " Monday ")
577+
except locale.Error:
578+
raise unittest.SkipTest('cannot set the en_US locale')
579+
567580
def test_locale_html_calendar_custom_css_class_month_name(self):
568581
try:
569582
cal = calendar.LocaleHTMLCalendar(locale='')

Misc/ACKS

+1
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ Nils Fischbeck
548548
Frederik Fix
549549
Tom Flanagan
550550
Matt Fleming
551+
Sean Fleming
551552
Hernán Martínez Foffani
552553
Benjamin Fogle
553554
Artem Fokin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Increase calendar test coverage for :meth:`calendar.LocaleTextCalendar.formatweekday`.

0 commit comments

Comments
 (0)