From c70a408d4e1fc5118959f924e71a997de862fb6b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 3 Jun 2022 16:26:24 +0300 Subject: [PATCH 1/4] gh-57539: Increase calendar coverage Co-authored-by: Sean Fleming --- Lib/test/test_calendar.py | 10 ++++++++++ Misc/ACKS | 1 + .../2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst | 1 + 3 files changed, 12 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index f76cbc9472a6e8..b4b27a63c54d14 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -564,6 +564,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='') diff --git a/Misc/ACKS b/Misc/ACKS index d0e18303434f22..6b5ab49e3bf0e7 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -548,6 +548,7 @@ Nils Fischbeck Frederik Fix Tom Flanagan Matt Fleming +Sean Fleming Hernán Martínez Foffani Benjamin Fogle Artem Fokin diff --git a/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst b/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst new file mode 100644 index 00000000000000..5fc09c103ae796 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst @@ -0,0 +1 @@ +Increase calendar coverage From 5288325920be1d37a617961dc61e4ae2b80818ca Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 3 Jun 2022 17:01:13 +0300 Subject: [PATCH 2/4] Skip test if locale not available --- Lib/test/test_calendar.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index b4b27a63c54d14..a5647b06e1f4c6 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -565,14 +565,18 @@ def test_locale_calendars(self): 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 ") + 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: + # cannot set the en_US locale -- skip test + raise unittest.SkipTest('cannot set the en_US locale') def test_locale_html_calendar_custom_css_class_month_name(self): try: From 646c782c06b6464993bd7499fce1f0432c6bfdeb Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 4 Jun 2022 19:38:46 +0300 Subject: [PATCH 3/4] Update Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- .../next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst b/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst index 5fc09c103ae796..0734b599f4ad95 100644 --- a/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst +++ b/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst @@ -1 +1 @@ -Increase calendar coverage +Increase calendar test coverage for :meth:`calendar.LocaleTextCalendar.formatweekday`. From 1952568f40182c4d3d9feabf60074a8e9a9cb326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 7 Jun 2022 09:59:05 +0200 Subject: [PATCH 4/4] Remove spurious comment and a spurious space --- Lib/test/test_calendar.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index a5647b06e1f4c6..3d9dcf12f2dad8 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -575,8 +575,7 @@ def test_locale_calendar_formatweekday(self): # For long widths, the full day name is used. self.assertEqual(cal.formatweekday(0, 10), " Monday ") except locale.Error: - # cannot set the en_US locale -- skip test - raise unittest.SkipTest('cannot set the en_US locale') + raise unittest.SkipTest('cannot set the en_US locale') def test_locale_html_calendar_custom_css_class_month_name(self): try: