Skip to content

gh-124176: Add special support for dataclasses to create_autospec - #124429

Merged
sobolevn merged 4 commits into
python:mainfrom
sobolevn:issue-124176
Sep 27, 2024
Merged

gh-124176: Add special support for dataclasses to create_autospec#124429
sobolevn merged 4 commits into
python:mainfrom
sobolevn:issue-124176

Conversation

@sobolevn

@sobolevnsobolevn commented Sep 24, 2024

Copy link
Copy Markdown
Member

Now creating autospecs from dataclass types is easier. We inspect all fields and add them to __dir__, so mock's spec will know about future dataclass instance fields.

@ericvsmithericvsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not a user of unittest.mock, but these changes look reasonable to me.

@carljmcarljm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks reasonable to me as well.

Comment threadLib/test/test_unittest/testmock/testhelpers.py Outdated

@cjw296cjw296 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Supportive of the change, just the code hygiene changes to make.

Comment threadLib/test/test_unittest/testmock/testhelpers.py
Comment threadLib/unittest/mock.py Outdated
Comment threadLib/unittest/mock.py Outdated
@bedevere-app

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@sobolevn

Copy link
Copy Markdown
MemberAuthor

@cjw296 done! 👍

Comment threadLib/unittest/mock.py Outdated

@ncoghlanncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! I especially like the test coverage.

@cjw296cjw296 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

@sobolevn
sobolevn merged commit 3a0e7f5 into python:mainSep 27, 2024
@sobolevn

Copy link
Copy Markdown
MemberAuthor

Thanks everyone! 🎉

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@sobolevn@carljm@ericvsmith@cjw296@ncoghlan