This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Attempt full test coverage of LocaleTextCalendar.formatweekday
Type: enhancement Stage: patch review
Components: Library (Lib), Tests Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Sean.Fleming, berker.peksag, iritkatriel, jesstess, rhettinger, serhiy.storchaka, terry.reedy
Priority: normal Keywords: easy

Created on 2011-11-03 06:14 by Sean.Fleming, last changed 2022-04-11 14:57 by admin.

File name Uploaded Description Edit
test_calendar.patch Sean.Fleming, 2011-11-03 06:14 review
issue13330.patch jesstess, 2014-04-27 20:43 review
Messages (6)
msg146895 - (view) Author: Sean Fleming (Sean.Fleming) Date: 2011-11-03 06:14
Patch includes new statements in test_localecalendars of CalendarTestCase such that coverage of LocaleTextCalendar.formatweekday should improve significantly. 

Feedback is appreciated.
msg217316 - (view) Author: Jessica McKellar (jesstess) * (Python triager) Date: 2014-04-27 20:43
Thanks for working to increase our test coverage, Sean.Fleming!

Looking at the current coverage, the there is one line in LocaleTextCalendar.formatweekday without coverage:

You add some additional tests, but they are mostly testing some very literal aspects of the implementation rather than the purpose of the function. For example:

+        self.assertRaises(IndexError, calendar.LocaleTextCalendar(locale='').formatweekday, 7, 1 )

It's true that this will raise an IndexError, but formatweekday isn't supposed to be called with these values.

I've added some tests that add coverage for the line that didn't have coverage, while focusing on the purpose of the function, namely to provide an appropriate day name when constrained to various widths.

* The patch passes the full test suite
* The patch passes `make patchcheck`
* The patch results in full coverage for LocaleTextCalendar.formatweekday

Coverage results, before and after:

$ ./python.exe ../coveragepy/ run --pylib --source=calendar Lib/test/ test_calendar
[1/1] test_calendar
1 test OK.
nitefly:cpython jesstess$ ./python.exe ../coveragepy/ report --show-missing
Name           Stmts   Miss  Cover   Missing
Lib/calendar     375     54    86%   511, 519, 541, 608-699, 703
$ patch -p1 < issue13330.patch 
patching file Lib/test/
patching file Misc/ACKS
$ ./python.exe ../coveragepy/ run --pylib --source=calendar Lib/test/ test_calendar
[1/1] test_calendar
1 test OK.
nitefly:cpython jesstess$ ./python.exe ../coveragepy/ report --show-missing
Name           Stmts   Miss  Cover   Missing
Lib/calendar     375     53    86%   511, 541, 608-699, 703

(519 was the one line without coverage inside LocaleTextCalendar.formatweekday)
msg255419 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-26 14:48
The test depends on the en_US locale. Only existing of POSIX locale is guarantied. The test should be skipped instead of failed if the en_US locale is not available. It would be nice to test also with other locales. For example with de_DE, fr_FR, tr_TR, ps_AF - these locales are used also in other tests.
msg255422 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-11-26 15:04
And it looks that only empty locale works on Windows (issue21731).
msg415814 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-22 21:24
The patch needs to be reviewed. If the tests are still relevant and increase coverage, it needs to be converted to a GitHub PR. Otherwise this issue can be closed.
msg415816 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-22 21:27
See also issue25528.
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57539
2022-03-22 21:27:37iritkatrielsetmessages: + msg415816
2022-03-22 21:24:56iritkatrielsetversions: + Python 3.11, - Python 3.4, Python 3.5
nosy: + iritkatriel

messages: + msg415814

keywords: + easy, - patch, needs review
2015-11-26 15:04:43serhiy.storchakasetmessages: + msg255422
2015-11-26 14:48:12serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg255419
2015-01-29 01:20:40berker.peksagsetnosy: + berker.peksag

versions: + Python 3.4
2014-04-27 20:43:06jesstesssetfiles: + issue13330.patch
versions: + Python 3.5, - Python 3.3
nosy: + jesstess

messages: + msg217316
2011-11-04 22:42:18terry.reedysetnosy: + rhettinger, terry.reedy
2011-11-03 08:58:03petri.lehtinensetkeywords: + needs review
stage: patch review
type: enhancement
components: + Library (Lib)
versions: + Python 3.3, - Python 3.4
2011-11-03 06:14:10Sean.Flemingcreate