8000 gh-109956: Also test `typing.NamedTuple` with `copy.replace` by sobolevn · Pull Request #109957 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109956: Also test typing.NamedTuple with copy.replace #109957

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

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Update Lib/test/test_copy.py
  • Loading branch information
serhiy-storchaka authored Oct 3, 2023
commit 2e3db6ffc145b9db7d6129e8d0e018e69a9293eb
1 change: 1 addition & 0 deletions Lib/test/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ class PointFromClass(NamedTuple):
p = Point(11, 22)
Copy link
Member

Choose a reason for hiding this comment

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

Should we test the class?

Suggested change
p = Point(11, 22)
p = Point(11, 22)
assert isinstance(copy.replace(p, x=12), Point)

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not? :)
Done.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I meant to test the copy, not the original p!

Copy link
Member

Choose a reason for hiding this comment

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

I did not notice this conversation (I can't see the text few lines above the line I'm looking at), but I added a test for a copy just before merging. I was puzzled as to why the test for the original was added, but decided not to drag the review out.

self.assertIsInstance(p, Point)
self.assertEqual(copy.replace(p), (11, 22))
self.assertIsInstance(copy.replace(p), Point)
self.assertEqual(copy.replace(p, x=1), (1, 22))
self.assertEqual(copy.replace(p, y=2), (11, 2))
self.assertEqual(copy.replace(p, x=1, y=2), (1, 2))
Expand Down
0