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-116789: Add more tests for inspect.getmembers #116802

Merged
merged 5 commits into from
Aug 18, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Mar 14, 2024

It basically checks that getmembers is equal dir(...) + getattr for these types.
I've covered all types that were mentioned in the docs.

@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Mar 14, 2024
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.

All these tests are just copies of each other. They do not contain anything specific to the specific type, so why add them? A test for arbitrary user object should be enough. They only depend on the result of dir(), if it returns an empty list, all tests will automatically pass.

@sobolevn
Copy link
Member Author

sobolevn commented Aug 7, 2024

Sorry, I lost this PR in the notifications at some point.

I addressed @serhiy-storchaka's feedback:

  • I added two classes: one for correct __dir__ and one for __dir__ with extra item that does not exist
  • I no longer use dict, checks are made specific
  • Extra tests are removed

Thanks a lot for the feedback and notification! 👍

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchaka: Do you want to review the updated new tests?

@sobolevn sobolevn added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Aug 18, 2024
@sobolevn
Copy link
Member Author

It was up for 2 weeks, so I am going to merge this, we can add more tests later. Thanks a lot for the reviews, they were very helpful.

@sobolevn sobolevn merged commit c15bfa9 into python:main Aug 18, 2024
36 checks passed
@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 18, 2024
…6802)

(cherry picked from commit c15bfa9)

Co-authored-by: sobolevn <mail@sobolevn.me>
@bedevere-app
Copy link

bedevere-app bot commented Aug 18, 2024

GH-123129 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Aug 18, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 18, 2024
…6802)

(cherry picked from commit c15bfa9)

Co-authored-by: sobolevn <mail@sobolevn.me>
@bedevere-app
Copy link

bedevere-app bot commented Aug 18, 2024

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

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Aug 18, 2024
sobolevn added a commit that referenced this pull request Aug 18, 2024
…#123130)

gh-116789: Add more tests for `inspect.getmembers` (GH-116802)
(cherry picked from commit c15bfa9)

Co-authored-by: sobolevn <mail@sobolevn.me>
jeremyhylton pushed a commit to jeremyhylton/cpython that referenced this pull request Aug 19, 2024
blhsing pushed a commit to blhsing/cpython that referenced this pull request Aug 22, 2024
vstinner pushed a commit that referenced this pull request Aug 26, 2024
…#123129)

gh-116789: Add more tests for `inspect.getmembers` (GH-116802)
(cherry picked from commit c15bfa9)

Co-authored-by: sobolevn <mail@sobolevn.me>
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