-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
spy: handle AttributeError with __getattribute__ #42
spy: handle AttributeError with __getattribute__ #42
Conversation
7bf8e07
to
590defc
Compare
def test_class_method_subclass_spy(mocker): | ||
class Base(object): | ||
|
||
@classmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be a classmethod
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it is now - I was pushing a fixup/amended commit.
Thanks a lot @blueyed! Could you please also write a new CHANGELOG entry? The timing is great, I was planning on publishing a new release today! 😄 |
590defc
to
b46075d
Compare
It does not work with Python 2 apparently: @skip_pypy
def test_static_method_subclass_spy(mocker):
class Base(object):
@staticmethod
def bar(arg):
return arg * 2
class Foo(Base):
pass
spy = mocker.spy(Foo, 'bar')
> assert Foo.bar(arg=10) == 20
E TypeError: unbound method bar() must be called with Foo instance as first argument (got nothing instead) (same with classmethod). Should the tests be skipped there? |
Hmmm that's a shame. Please |
I have noticed that `spy` did not work on functions that are not defined in the class itself, but a parent class. This patch fixes this.
b46075d
to
645680a
Compare
Done. |
Thanks again! 😄 |
I have noticed that
spy
did not work on functions that are not definedin the class itself, but a parent class. This patch fixes this.