bpo-23078: Add support for staticmethod and classmethod to mock created with autospec by tirkarthi ยท Pull Request #11613 ยท python/cpython

@tirkarthi

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

@tirkarthi

@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

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.

#Issue23078
def test_create_autospec_staticmethod(self):
class TestClass:
method = staticmethod(lambda: None)

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.

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.

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 :).

Choose a reason for hiding this comment

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

@tirkarthi

mariocj89

Choose a reason for hiding this comment

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

Great! ๐Ÿ˜„

@berkerpeksag

@berkerpeksag

berkerpeksag

@miss-islington

Thanks @tirkarthi for the PR, and @berkerpeksag for merging it ๐ŸŒฎ๐ŸŽ‰.. I'm working now to backport this PR to: 3.7.
๐Ÿ๐Ÿ’โ›๐Ÿค–

@miss-islington

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

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)