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

Remove raw asserts in test_typing.py #104951

Merged
merged 3 commits into from
May 26, 2023
Merged

Conversation

JelleZijlstra
Copy link
Member

No description provided.

Comment on lines 7107 to 7108
self.assertEqual(Point2Dor3D.__required_keys__, frozenset(['x', 'y']))
self.assertEqual(Point2Dor3D.__optional_keys__, frozenset(['z']))
Copy link
Member

Choose a reason for hiding this comment

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

The changes in this PR look good. But it looks like we have a lot of tests in this test class that do things like self.assertEqual(some_frozenset, frozenset(['x', 'y'])). That looks like it's checking that some_frozenset is a frozenset, but it's actually not, because frozensets and sets with the same members compare equal. So I wonder if we should be doing this:

Suggested change
self.assertEqual(Point2Dor3D.__required_keys__, frozenset(['x', 'y']))
self.assertEqual(Point2Dor3D.__optional_keys__, frozenset(['z']))
self.assertEqual(Point2Dor3D.__required_keys__, {'x', 'y'})
self.assertIsInstance(Point2Dor3D.__required_keys__, frozenset)
self.assertEqual(Point2Dor3D.__optional_keys__, {'z'})
self.assertIsInstance(Point2Dor3D.__optional_keys__, frozenset)

But maybe we don't need to assert the type of __required_keys__ every time we want to check the contents of the set.

Copy link
Member

Choose a reason for hiding this comment

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

Anyway, we don't need to change that in this PR; the changes here are definitely good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Might as well do that in this PR too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed a few new asserts checking that it's really a frozenset

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM

@AlexWaygood AlexWaygood merged commit 2cb4456 into python:main May 26, 2023
17 of 18 checks passed
@miss-islington
Copy link
Contributor

Thanks @JelleZijlstra for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2023
(cherry picked from commit 2cb4456)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@bedevere-bot
Copy link

GH-104978 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label May 26, 2023
@bedevere-bot
Copy link

GH-104979 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label May 26, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2023
(cherry picked from commit 2cb4456)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
AlexWaygood pushed a commit that referenced this pull request May 26, 2023
Remove raw asserts in test_typing.py (GH-104951)
(cherry picked from commit 2cb4456)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
AlexWaygood pushed a commit that referenced this pull request May 26, 2023
Remove raw asserts in test_typing.py (GH-104951)
(cherry picked from commit 2cb4456)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip issue 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