]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-57539: Increase calendar test coverage (GH-93468) (GH-93565)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 7 Jun 2022 10:20:49 +0000 (03:20 -0700)
committerGitHub <noreply@github.com>
Tue, 7 Jun 2022 10:20:49 +0000 (12:20 +0200)
(cherry picked from commit f0d0be3493fc5855eccfe0fbb3f25bf12760041f)

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>
Lib/test/test_calendar.py
Misc/ACKS
Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst [new file with mode: 0644]

index 5ae2b66ff3b5fe194345386b54564916086df163..dc49ac1c0f1e62b50b0da522808cc17987894ad5 100644 (file)
@@ -564,6 +564,19 @@ class CalendarTestCase(unittest.TestCase):
         new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
         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):
         try:
             cal = calendar.LocaleHTMLCalendar(locale='')
index 7a363b99836a21f382792ebc695d6e668d5aa5a0..c690200c15dd1a535c0b22f7b6c5276d81bf6d0e 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -545,6 +545,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 (file)
index 0000000..0734b59
--- /dev/null
@@ -0,0 +1 @@
+Increase calendar test coverage for :meth:`calendar.LocaleTextCalendar.formatweekday`.