Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-69714: Make calendar module fully tested #93655

Merged
merged 29 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
cb0523e
Increased test coverage of calendar module
rohitmediratta Nov 1, 2015
78935da
gh-69714: Restore the test thrown out by cb0523e67c
bxsx Jun 6, 2022
0dd6321
gh-69714: Increase test coverage for `calendar.Locale{Text|HTML}Calen…
bxsx Jun 6, 2022
69c8f4f
gh-69714: Add missing test cases for custom locale in `calendar.Local…
bxsx Jun 7, 2022
a96786c
gh-69714: Remove unreachable code (and increase test coverage)
bxsx Jun 7, 2022
636b4e1
gh-69714: Increase CLI tests coverage
bxsx Jun 9, 2022
238c527
gh-69714: Add more test cases to `calendar` cmdline
bxsx Jun 9, 2022
b850c92
gh-69714: Increase test coverage for `calendar` cmdline
bxsx Jun 9, 2022
ab069a4
gh-57539: Add tests for `LocaleTextCalendar.formatweekday`
jesstess Apr 27, 2014
f1febfc
gh-69714: Increase test coverage for `LocaleTextCalendar.formatmonthn…
bxsx Jun 9, 2022
e9e8825
Merge branch 'main' into gh-69714/calendar-test-coverage
bxsx Jun 9, 2022
827e664
Remove comment
bxsx Jun 9, 2022
d28e2e4
gh-69714: Reorder locale in the test case
bxsx Jun 9, 2022
bbdc393
gh-69714: Extract test case
bxsx Jun 9, 2022
8914cdc
Update ACKS
bxsx Jun 9, 2022
68adf69
Add NEWS entry
bxsx Jun 9, 2022
40e0da3
Revert "gh-69714: Remove unreachable code (and increase test coverage)"
bxsx Jun 9, 2022
2b6f1f9
Expand the try clause to calls to `LocaleTextCalendar.formatmonthname…
bxsx Jun 9, 2022
64cb029
Revert "Revert "gh-69714: Remove unreachable code (and increase test …
bxsx Jun 9, 2022
2b2c8ef
Add missing whitespace
bxsx Jun 10, 2022
8b7bc06
gh-69714: Move the validation to the beginning of the function
bxsx Jun 11, 2022
de21a51
gh-69714: Increase test coverage for illegal arguments
bxsx Jun 11, 2022
ab5a508
Revert "gh-69714: Add more test cases to `calendar` cmdline"
bxsx Jun 11, 2022
1558845
Clean up redundant arguments
bxsx Jun 11, 2022
0aa0caf
gh-69417: Include cases with odd widths in `formatmonthname`
bxsx Jun 11, 2022
e73fc9e
gh-69714: Split tests for LocaleTextCalendar and LocaleHTMLCalendar
bxsx Jun 11, 2022
5b094ae
Merge branch 'main' into gh-69714/calendar-test-coverage
iritkatriel Feb 18, 2023
87feac0
Merge branch 'main' into gh-69714/calendar-test-coverage
bxsx Jul 20, 2023
81d09b2
Merge branch 'main' into gh-69714/calendar-test-coverage
bxsx Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Lib/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,6 @@ def __enter__(self):
_locale.setlocale(_locale.LC_TIME, self.locale)

def __exit__(self, *args):
if self.oldlocale is None:
return
bxsx marked this conversation as resolved.
Show resolved Hide resolved
_locale.setlocale(_locale.LC_TIME, self.oldlocale)


Expand Down Expand Up @@ -660,7 +658,7 @@ def timegm(tuple):
return seconds


def main(args):
def main(args=None):
bxsx marked this conversation as resolved.
Show resolved Hide resolved
import argparse
parser = argparse.ArgumentParser()
textgroup = parser.add_argument_group('text only arguments')
Expand Down Expand Up @@ -717,7 +715,7 @@ def main(args):
help="month number (1-12, text only)"
)

options = parser.parse_args(args[1:])
options = parser.parse_args(args)

if options.locale and not options.encoding:
parser.error("if --locale is specified --encoding is required")
Expand All @@ -726,6 +724,9 @@ def main(args):
locale = options.locale, options.encoding

if options.type == "html":
if options.month:
parser.error("incorrect number of arguments")
bxsx marked this conversation as resolved.
Show resolved Hide resolved
sys.exit(1)
bxsx marked this conversation as resolved.
Show resolved Hide resolved
if options.locale:
cal = LocaleHTMLCalendar(locale=locale)
else:
Expand All @@ -737,11 +738,8 @@ def main(args):
write = sys.stdout.buffer.write
if options.year is None:
write(cal.formatyearpage(datetime.date.today().year, **optdict))
elif options.month is None:
write(cal.formatyearpage(options.year, **optdict))
else:
parser.error("incorrect number of arguments")
sys.exit(1)
write(cal.formatyearpage(options.year, **optdict))
else:
if options.locale:
cal = LocaleTextCalendar(locale=locale)
Expand All @@ -765,4 +763,4 @@ def main(args):


if __name__ == "__main__":
main(sys.argv)
main()
Loading