Skip to content

Commit b4fdd8c

Browse files
miss-islingtonAA-Turnerambvhugovk
authored
gh-57539: Increase calendar test coverage (GH-93468) (GH-93565)
(cherry picked from commit f0d0be3) Co-authored-by: Sean Fleming Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Łukasz Langa <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent c7b5a2d commit b4fdd8c

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
@@ -545,6 +545,7 @@ Nils Fischbeck
545545
Frederik Fix
546546
Tom Flanagan
547547
Matt Fleming
548+
Sean Fleming
548549
Hernán Martínez Foffani
549550
Benjamin Fogle
550551
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)