GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-69714: Make `calendar` module fully tested by bxsx · Pull Request #93655 · python/cpython

Conversation

@bxsx

@bxsx bxsx commented Jun 9, 2022 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Resolves #69714 by increasing test coverage of calendar module to 100%[1].

Coverage reports

Before

main branch test coverage report for calendar module:

$ ./python.exe coveragepy report --show-missing
Name              Stmts   Miss  Cover   Missing
-----------------------------------------------
Lib/calendar.py     399     60    85%   559, 564-570, 582, 602, 664-764, 768
-----------------------------------------------
TOTAL               399     60    85%

After

The PR branch test coverage report for calendar module:

$ ./python.exe coveragepy report --show-missing
Name              Stmts   Miss  Cover   Missing
-----------------------------------------------
Lib/calendar.py     397      3    99%   722, 742, 766
-----------------------------------------------
TOTAL               397      3    99%

Footnotes

[1] The remaining three lines are:

$ cat -n Lib/calendar.py | sed -n '722p;742p;766p'
   722	        sys.exit(1)
   742	            sys.exit(1)
   766	    main()
$

and they are, in fact, already covered by tests (only not reported by coveragepy).

  • Issue: Attempt to further increase test coverage of calendar module #69714

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rohitmediratta and others added 11 commits June 6, 2022 02:29
@rohitmediratta @bxsx
Increased test coverage of calendar module
cb0523e
@bxsx
pythongh-69714: Restore the test thrown out by cb0523e
78935da
@bxsx
pythongh-69714: Increase test coverage for `calendar.Locale{Text|HTML…
0dd6321
…}Calendar(locale='')`
@bxsx
pythongh-69714: Add missing test cases for custom locale in `calendar…
69c8f4f
….Locale{Text|HTML}Calendar`

There are 3 paths to use `locale` argument in
`calendar.Locale{Text|HTML}Calendar.__init__(..., locale=None)`:
(1) `locale=None` -- denotes the "default locale"[1]
(2) `locale=""` -- denotes the native environment
(3) `locale=other_valid_locale` -- denotes a custom locale

So far case (2) is covered and case (1) is in 78935da (same branch).
This commit adds a remaining case (3).

[1] In the current implementation, this translates into the following
approach:

GET current locale
IF current locale == "C" THEN
  SET current locale TO ""
  GET current locale
ENDIF
@bxsx
pythongh-69714: Remove unreachable code (and increase test coverage)
a96786c
This condition cannot be true. `_locale.setlocale()` from the C module
raises `locale.Error` instead of returning `None` for
`different_locale.__enter__` (where `self.oldlocale` is set).
@bxsx
pythongh-69714: Increase CLI tests coverage
636b4e1
@bxsx
pythongh-69714: Add more test cases to calendar cmdline
238c527
@bxsx
pythongh-69714: Increase test coverage for calendar cmdline
b850c92
@jesstess @bxsx
pythongh-57539: Add tests for LocaleTextCalendar.formatweekday
ab069a4
This patch has already been applied to `main` branch (via pythongh-93468), but
with wrong copyright. After merging this commit to `main`, git `Author`
metadata will be updated to the original author.
@bxsx
pythongh-69714: Increase test coverage for `LocaleTextCalendar.format…
f1febfc
…monthname`
@bxsx
Merge branch 'main' into pythongh-69714/calendar-test-coverage
e9e8825
@ghost

ghost commented Jun 9, 2022 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

  • [email protected]
  • [email protected]

Click the button to sign:
CLA not signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Jun 9, 2022

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting review label Jun 9, 2022
AA-Turner
AA-Turner reviewed Jun 9, 2022
View reviewed changes

@AA-Turner AA-Turner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also cc: @hugovk (who I know has different opinions on testing to me!)

A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner AA-Turner added stdlib Standard Library Python modules in the Lib/ directory type-feature A feature request or enhancement tests Tests in the Lib/test dir labels Jun 9, 2022
@bxsx @AA-Turner
Remove comment
827e664
Co-authored-by: Adam Turner <[email protected]>
@bedevere-bot

bedevere-bot commented Jun 9, 2022

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner AA-Turner mentioned this pull request Jun 9, 2022
Attempt to further increase test coverage of calendar module #69714
Closed
@AA-Turner

AA-Turner commented Jun 9, 2022

Copy link
Copy Markdown
Member

You will need a NEWS entry, along the lines of Added tests to :mod:`calendar` to achieve full test coverage.

A

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bxsx added 4 commits June 9, 2022 21:24
@bxsx
pythongh-69714: Reorder locale in the test case
d28e2e4
@bxsx
pythongh-69714: Extract test case
bbdc393
@bxsx
Update ACKS
8914cdc
@bxsx
Add NEWS entry
68adf69
@bxsx

bxsx commented Jun 9, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@AA-Turner
You will need a NEWS entry, along the lines of Added tests to :mod:`calendar` to achieve full test coverage.

Thanks! I just added it.

Another problem is the lack of CLA signatures from @jesstess and @rohitmediratta. The applied patches were quite old, so I'm not sure the email addresses are up to date (I don't know if the bot is sending emails about the CLA). Anyway, it looks like GitHub has assigned these commits to the correct usernames, so I'm tagging Jessica and Rohit in this comment to help notify :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Jun 9, 2022

Copy link
Copy Markdown
Member

You'll need to fix the Ubuntu failures in test_locale_calendar_formatmonthname too:

Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_calendar.py", line 650, in test_locale_calendar_formatmonthname
    self.assertEqual(cal.formatmonthname(2022, 6, 2, withyear=False), "June")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/calendar.py", line 588, in formatmonthname
    with different_locale(self.locale):
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/calendar.py", line 555, in __enter__
    _locale.setlocale(_locale.LC_TIME, self.locale)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/locale.py", line 626, in setlocale
    return _setlocale(category, locale)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
locale.Error: unsupported locale setting

This may be another test-skipping scenario, I don't know what the values it is trying to set are though so I can't guess much further.

A

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner

AA-Turner commented Jun 9, 2022

Copy link
Copy Markdown
Member

I'm tagging Jessica and Rohit in this comment to help notify

You might also want to consider emailing the two of them if you don't hear back, neither seem to have much recent publicly shown activity on GH.

A

bxsx reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bxsx

bxsx commented Jun 9, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@AA-Turner
You'll need to fix the Ubuntu failures in test_locale_calendar_formatmonthname too:

This may be another test-skipping scenario, I don't know what the values it is trying to set are though so I can't guess much further.

Or maybe (based on the traceback) it's related to one of the corner cases from #93655 (comment)?
I don't have access to Ubuntu at the moment but I can revert that change and see what happens before further investigation.
This is a newly added test BTW.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bxsx
Revert "pythongh-69714: Remove unreachable code (and increase test co…
40e0da3
…verage)"

This reverts commit a96786c.
@AA-Turner

AA-Turner commented Jun 9, 2022

Copy link
Copy Markdown
Member

I can revert that change and see what happens before further investigation.

Sadly it doesn't seem to have worked :(

A

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bxsx added 2 commits June 10, 2022 01:01
@bxsx
Expand the try clause to calls to `LocaleTextCalendar.formatmonthname…
2b6f1f9
…()`.

This method temporarily changes the current locale to the given locale,
so `_locale.setlocale()` may raise `local.Error`.
@bxsx
Revert "Revert "pythongh-69714: Remove unreachable code (and increase…
64cb029
… test coverage)""

This reverts commit 40e0da3.
So it brings back commit a96786c.
@bxsx

bxsx commented Jun 10, 2022

Copy link
Copy Markdown
Contributor Author

Sadly it doesn't seem to have worked :(

Yes, I misread the traceback in a rush before disconnecting, but I wanted to kick off builds to get results when I get back. Time saving ;)

For now, I have restored a96786c.

However, it is true that the cause of the problem is related to #31214 and as you correctly predicted, this is another test-skipping scenario. Fixed in 2b6f1f9.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bxsx
Add missing whitespace
2b2c8ef
@bxsx

bxsx commented Jun 10, 2022

Copy link
Copy Markdown
Contributor Author

test_illegal_arguments and test_too_many_arguments fail in Azure Pipelines PR.
I will try to investigate it, but for now I'm marking this PR as a draft.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bxsx
bxsx marked this pull request as draft June 10, 2022 02:05
hugovk
hugovk reviewed Jun 10, 2022
View reviewed changes
Comment thread Lib/test/test_calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

bxsx added 4 commits June 11, 2022 19:26
@bxsx
pythongh-69714: Move the validation to the beginning of the function
8b7bc06
No need to process the function.
This also helps in supporting CLI testing.
@bxsx
pythongh-69714: Increase test coverage for illegal arguments
de21a51
@bxsx
Revert "pythongh-69714: Add more test cases to calendar cmdline"
ab5a508
These tests are now part of `test_illegal_arguments`.
This reverts commit 238c527.
@bxsx
Clean up redundant arguments
1558845
@bxsx

bxsx commented Jun 11, 2022

Copy link
Copy Markdown
Contributor Author

test_illegal_arguments and test_too_many_arguments fail in Azure Pipelines PR.
I will try to investigate it, but for now I'm marking this PR as a draft.

Fixed in 8b7bc06.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bxsx added 2 commits June 11, 2022 20:28
@bxsx
pythongh-69417: Include cases with odd widths in formatmonthname
0aa0caf
@bxsx
pythongh-69714: Split tests for LocaleTextCalendar and LocaleHTMLCale…
e73fc9e
…ndar
@bxsx

bxsx commented Jun 11, 2022

Copy link
Copy Markdown
Contributor Author

Ok, all comments are now addressed and resolved. All tests pass successfully. ✔️
Still missing CLA signatures from @jesstess and @rohitmediratta. I will email them directly. 🤞

I think the PR is ready for another round of reviews ;-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bxsx
bxsx marked this pull request as ready for review June 11, 2022 19:06
AA-Turner
AA-Turner reviewed Jun 11, 2022
View reviewed changes

@AA-Turner AA-Turner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated tests look good, I'll wait for Hugo's thoughts.

A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bxsx reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bxsx
bxsx requested review from AA-Turner and hugovk June 12, 2022 17:01
@bxsx

bxsx commented Jun 17, 2022

Copy link
Copy Markdown
Contributor Author

Good news for the weekend.

Rohit signed the CLA. Thanks again @rohitmediratta!

I also looked at @jesstess GH profile and I believe the missing CLA has already been signed by Jessica as she is a former director of the Python Software Foundation and a member of @python.

I've emailed [email protected] to sort this out.

AA-Turner, hugovk, and arhadthedev reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel
Merge branch 'main' into pythongh-69714/calendar-test-coverage
5b094ae
@terryjreedy

terryjreedy commented Feb 24, 2023

Copy link
Copy Markdown
Member

Here is the holdup situation:
For https://bugs.python.org/issue13330, Attempt full test coverage of LocaleTextCalendar.formatweekday
Sean Fleming, no CLA recorded, uploaded a patch 2011-11-03 02:14.
bpo user jesstess Jessica McKellar, https://bugs.python.org/user11041, signed the CLA "on: 2013-04-12.20:00:00".
She more or less rejected Sean's patch and uploaded a much different patch,
https://bugs.python.org/file35060/issue13330.patch on 2014-04-27 16:43.
Serhiy Storchaka mentioned a couple of problems.

When moved to gh, issue became #57539. Irit Katriel requested gh PR and mentioned this issue.
Last June, hugovk converted Jessica's patch to a PR, with the correction requested by Serhiy.
The commit message mistakenly said "Co-authored-by: Sean Fleming". This apparently did not trigger the CLA bot of the time to request a signature from Sean. ambv merged and backported on June 7, 2022.

On June 9, bxsx added ab069a4, which added Jessica's original code, without the Serhiy correction. It somehow credited Jessica as author. Fortunately, the deletion of the correction is somehow not in the merged patch. Unfortunately, it fooled the CLA bot into thinking that she was an author of this PR.

@ambv This PR, which has had a lot of work by multiple people, is blocked by the false 'need' for an unobtainable signature from @jesstess Jessica McKeller, who did not contribute to this PR. Should reverting ab069a4 fix the mistake or is something else needed. If so, can you override the bot? (Though a final review may be needed.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bxsx added 2 commits July 20, 2023 17:05
@bxsx
Merge branch 'main' into pythongh-69714/calendar-test-coverage
87feac0
@bxsx
Merge branch 'main' into pythongh-69714/calendar-test-coverage
81d09b2
@ambv
ambv merged commit 2aba047 into python:main Jul 22, 2023
@bedevere-bot bedevere-bot removed the awaiting review label Jul 22, 2023
StanFromIreland
StanFromIreland reviewed Oct 16, 2025
View reviewed changes
Comment thread Lib/calendar.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@StanFromIreland StanFromIreland StanFromIreland left review comments
@hugovk hugovk Awaiting requested review from hugovk
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stdlib Standard Library Python modules in the Lib/ directory tests Tests in the Lib/test dir type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Attempt to further increase test coverage of calendar module

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@bxsx @bedevere-bot @AA-Turner @terryjreedy @vstinner @hugovk @StanFromIreland @ambv @rohitmediratta @jesstess @iritkatriel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.