Skip to content

bpo-23078: Add support for staticmethod and classmethod to mock created with autospec#11613

Merged
berkerpeksag merged 5 commits into
python:masterfrom
tirkarthi:bpo23078
Apr 22, 2019
Merged

bpo-23078: Add support for staticmethod and classmethod to mock created with autospec#11613
berkerpeksag merged 5 commits into
python:masterfrom
tirkarthi:bpo23078

Conversation

@tirkarthi

@tirkarthi tirkarthi commented Jan 18, 2019

Copy link
Copy Markdown
Member

Add support for staticmethod and classmethod to mock created with autospec. Patch by @felipeochoa converted into a PR.

Co-authored-by: Felipe felipe.nospam.ochoa@gmail.com

https://bugs.python.org/issue23078

tirkarthi and others added 2 commits January 18, 2019 23:06
Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
@tirkarthi

Copy link
Copy Markdown
Member Author

@mariocj89 @cjw296 Friendly ping. I have converted the patch from the tracker to PR attributing to original author. It was a frequently requested mock feature and I would be happy to act on review comments for this one.

Thanks.

@mariocj89 mariocj89 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.

Great!, small nitpicks if you want to pick them.

Comment thread Lib/unittest/test/testmock/testmock.py Outdated
#Issue23078
def test_create_autospec_staticmethod(self):
class TestClass:
method = staticmethod(lambda: None)

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.

It might be easier to read with the common syntax decorating the method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, changed to decorators 👍

@@ -0,0 +1,2 @@
Add support for staticmethod and classmethod with autospec. Based on patch
by Felipe.

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.

You might want to include Felipe's surname. And you can also get credit for this :).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, made the changes. cc : @felipeochoa

@mariocj89 mariocj89 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.

Great! 😄

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @tirkarthi for the PR, and @berkerpeksag for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @tirkarthi and @berkerpeksag, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 9b21856b0fcda949de239edc7aa6cf3f2f4f77a3 3.7

berkerpeksag pushed a commit to berkerpeksag/cpython that referenced this pull request Apr 22, 2019
…ec() (pythonGH-11613)

Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>

(cherry picked from commit 9b21856)
@bedevere-bot

Copy link
Copy Markdown

GH-12901 is a backport of this pull request to the 3.7 branch.

berkerpeksag added a commit that referenced this pull request Apr 22, 2019
…ec() (GH-11613)

Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>

(cherry picked from commit 9b21856)
Sign up for free to 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.

6 participants