derwiki-adroll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Assigning a bound method to a mock magic method fails #98

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

{{{
>>> 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
}}}

Original issue reported on code.google.com by fuzzyman on 22 Jun 2011 at 2:26

GoogleCodeExporter commented 9 years ago
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.

Original comment by fuzzyman on 22 Jun 2011 at 2:59

GoogleCodeExporter commented 9 years ago

Original comment by fuzzyman on 17 Jul 2011 at 1:09