[Python-checkins] gh-57539: Increase calendar test coverage (GH-93468) (GH-93565)
ambv
webhook-mailer at python.org
Tue Jun 7 06:21:04 EDT 2022
https://github.com/python/cpython/commit/b4fdd8ca298437943b08e82842325e3c7d814fbe
commit: b4fdd8ca298437943b08e82842325e3c7d814fbe
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2022-06-07T12:20:49+02:00
summary:
gh-57539: Increase calendar test coverage (GH-93468) (GH-93565)
(cherry picked from commit f0d0be3493fc5855eccfe0fbb3f25bf12760041f)
Co-authored-by: Sean Fleming
Co-authored-by: Adam Turner <9087854+AA-Turner at users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz at langa.pl>
Co-authored-by: Hugo van Kemenade <hugovk at users.noreply.github.com>
files:
A Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst
M Lib/test/test_calendar.py
M Misc/ACKS
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 5ae2b66ff3b5f..dc49ac1c0f1e6 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -564,6 +564,19 @@ 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):
+ 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='')
diff --git a/Misc/ACKS b/Misc/ACKS
index 7a363b99836a2..c690200c15dd1 100644
--- 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
index 0000000000000..0734b599f4ad9
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2022-06-03-16-26-04.gh-issue-57539.HxWgYO.rst
@@ -0,0 +1 @@
+Increase calendar test coverage for :meth:`calendar.LocaleTextCalendar.formatweekday`.
More information about the Python-checkins
mailing list