spec checking goes awry when replacing a class

Bug #794351 reported by Michael Hudson-Doyle
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mocker
New
Undecided
Unassigned

Bug Description

Best explained by example perhaps:

mwh@grond:trunk$ cat t.py
class C(object):
 def __init__(self, a): pass
 def __call__(self, *args): pass

import mocker
m = mocker.Mocker()
m_C = m.replace(C, passthrough=False)
m_C(mocker.ARGS, mocker.KWARGS)
m.replay()
C(a=1)
mwh@grond:trunk$ python t.py
Traceback (most recent call last):
  File "t.py", line 10, in <module>
    C(a=1)
  File "/home/mwh/canonical/repos/mocker/trunk/mocker.py", line 1221, in __call__
    return self.__mocker_act__("call", args, kwargs)
  File "/home/mwh/canonical/repos/mocker/trunk/mocker.py", line 1197, in __mocker_act__
    raise AssertionError(os.linesep.join(message))
AssertionError: [Mocker] Unmet expectation:

=> m_C(ARGS, KWARGS)
 - Run: m_C(a=1)
 - Specification is __call__(*args): unknown kwargs: a

I think that the basic problem is that, if you see a call to an object, accessing __call__ on that object is not actually the right thing to do in all cases! Accessing the __call__ on the type is closer, but for types its worth making a special case and checking the signature of __init__ I guess.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.