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

Conversation

sobolevn
Copy link
Member
@sobolevn sobolevn commented Sep 27, 2023

I've also added PointFromInheritance, since it is a very common pattern.

y: int = 0
for Point in (PointFromCall, PointFromInheritance, PointFromClass):
with self.subTest(Point=Point):
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.

< 8000 /div>
Copy link
Member
@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

I did not think that such tests were necessary and that this was the right place for such tests. But I won't mind if you want to add them here.

@serhiy-storchaka serhiy-storchaka merged commit bb2e96f into python:main Oct 3, 2023
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.

3 participants
0