spec checking goes awry when replacing a class
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/
return self.__
File "/home/
raise AssertionError(
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.