[Python-checkins] gh-101377: improving test_locale_calendar_formatweekday of calendar (GH-101378)

miss-islington webhook-mailer at python.org
Tue Mar 14 23:00:35 EDT 2023


https://github.com/python/cpython/commit/8aa07b9c8ae0203aa6e85b2b5556ee1700525672
commit: 8aa07b9c8ae0203aa6e85b2b5556ee1700525672
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-03-14T20:00:28-07:00
summary:

gh-101377: improving test_locale_calendar_formatweekday of calendar (GH-101378)


---------

(cherry picked from commit 5e0865f22eed9f3f3f0e912c4ada196effbd8ce0)

Co-authored-by: Andre Hora <andrehora at users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>

files:
A Misc/NEWS.d/next/Tests/2023-01-27-18-10-40.gh-issue-101377.IJGpqh.rst
M Lib/test/test_calendar.py

diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 3d9dcf12f2da..ccfbeede0be9 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -568,11 +568,15 @@ def test_locale_calendar_formatweekday(self):
         try:
             # formatweekday uses different day names based on the available width.
             cal = calendar.LocaleTextCalendar(locale='en_US')
+            # For really short widths, the abbreviated name is truncated.
+            self.assertEqual(cal.formatweekday(0, 1), "M")
+            self.assertEqual(cal.formatweekday(0, 2), "Mo")
             # For short widths, a centered, abbreviated name is used.
+            self.assertEqual(cal.formatweekday(0, 3), "Mon")
             self.assertEqual(cal.formatweekday(0, 5), " Mon ")
-            # For really short widths, even the abbreviated name is truncated.
-            self.assertEqual(cal.formatweekday(0, 2), "Mo")
+            self.assertEqual(cal.formatweekday(0, 8), "  Mon   ")
             # For long widths, the full day name is used.
+            self.assertEqual(cal.formatweekday(0, 9), "  Monday ")
             self.assertEqual(cal.formatweekday(0, 10), "  Monday  ")
         except locale.Error:
             raise unittest.SkipTest('cannot set the en_US locale')
diff --git a/Misc/NEWS.d/next/Tests/2023-01-27-18-10-40.gh-issue-101377.IJGpqh.rst b/Misc/NEWS.d/next/Tests/2023-01-27-18-10-40.gh-issue-101377.IJGpqh.rst
new file mode 100644
index 000000000000..a9c19ce060e3
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2023-01-27-18-10-40.gh-issue-101377.IJGpqh.rst
@@ -0,0 +1 @@
+Improved test_locale_calendar_formatweekday of calendar.



More information about the Python-checkins mailing list