My favorites | Sign in
Project Home Downloads Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 98: Assigning a bound method to a mock magic method fails
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  fuzzyman


Sign in to add a comment
 
Project Member Reported by fuzzyman, Jun 22, 2011

{{{
>>> from mock import Mock
>>> m = Mock()
>>> d = {}
>>> m.__iter__ = d.__iter__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mock.py", line 687, in __setattr__
    value = mocksignature(value, real, skipfirst=True)
  File "mock.py", line 272, in mocksignature
    signature, func = _getsignature(func, skipfirst)
  File "mock.py", line 119, in _getsignature
    regargs, varargs, varkwargs, defaults = inspect.getargspec(func)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.py", line 803, in getargspec
    raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function
}}}
Jun 22, 2011
Project Member #1 fuzzyman
Note that I'm not so sure this code should *succeed* (protocol methods need to take "self" so a bound method probably can't work). However it is nice and simple - an intuitive way to delegate to another object - so it would be *nice* if it worked.

Even if it can't be made to work without horrible special casing, the failure message could be better.
Status: New
Jul 17, 2011
Project Member #2 fuzzyman
(No comment was entered for this change.)
Labels: -Milestone-Release0.7
Sign in to add a comment

Powered by Google Project Hosting