Repository navigation
Attempt full test coverage of LocaleTextCalendar.formatweekday #57539
Description
Activity
Patch includes new statements in test_localecalendars of CalendarTestCase such that coverage of LocaleTextCalendar.formatweekday should improve significantly.
Feedback is appreciated.
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
on Nov 3, 2011 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: http://hg.python.org/cpython/file/e159cb0d955b/Lib/calendar.py#l519.
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/regrtest.py 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 < bpo-13330.patch
patching file Lib/test/test_calendar.py
patching file Misc/ACKS
$ ./python.exe ../coveragepy/ run --pylib --source=calendar Lib/test/regrtest.py 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)
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.
And it looks that only empty locale works on Windows (bpo-21731).
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.
See also bpo-25528.
- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on May 20, 2022 This hasn't been converted into a PR, if someone would like to we can re-open this issue in the future.
A
- removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Jun 3, 2022 - added a commit that references this issue
on Jun 3, 2022 I'll convert it. It might be worth keeping these easy issues open as they're good for new contributors to get started (and linked to from the devguide: https://devguide.python.org/fixingissues/).
Reacted by Adam Turner and Alex Waygood- added a commit that references this issue
on Jun 7, 2022 - added a commit that references this issue
on Jun 9, 2022 - added a commit that references this issue
on Jun 26, 2022
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: