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

bpo-46484:Add test for Calendar.iterweekdays #30825

Merged
merged 5 commits into from Apr 4, 2022

Conversation

180909
Copy link
Contributor

@180909 180909 commented Jan 23, 2022

Lib/test/test_calendar.py Outdated Show resolved Hide resolved
for firstweekday in range(7):
cal = calendar.Calendar(firstweekday)
week = list(cal.iterweekdays())
self.assertEqual(week[0], firstweekday)
self.assertEqual(week[-1], (firstweekday - 1) % 7)
self.assertEqual(week, result[firstweekday])
Copy link
Member

@iritkatriel iritkatriel Apr 4, 2022

Choose a reason for hiding this comment

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

You could write this test like this:

week0 = list(range(7))
for firstweekday in range(7):
    cal = calendar.Calendar(firstweekday)
    week = list(cal.iterweekdays())
    expected = week0[firstweekday:] + week0[:firstweekday]
    self.assertEqual(week, expected)

@iritkatriel iritkatriel merged commit 48269ea into python:main Apr 4, 2022
12 checks passed
@miss-islington
Copy link
Contributor

miss-islington commented Apr 4, 2022

Thanks @180909 for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒🤖

@bedevere-bot
Copy link

bedevere-bot commented Apr 4, 2022

GH-32307 is a backport of this pull request to the 3.10 branch.

@bedevere-bot
Copy link

bedevere-bot commented Apr 4, 2022

GH-32308 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 4, 2022
(cherry picked from commit 48269ea)

Co-authored-by: 180909 <734461790@qq.com>
miss-islington added a commit that referenced this pull request Apr 4, 2022
(cherry picked from commit 48269ea)

Co-authored-by: 180909 <734461790@qq.com>
miss-islington added a commit that referenced this pull request Apr 4, 2022
(cherry picked from commit 48269ea)

Co-authored-by: 180909 <734461790@qq.com>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
(cherry picked from commit 48269ea)

Co-authored-by: 180909 <734461790@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants