1
例如,在t.py如果方法在另一個方法中被調用兩次,如何assert_called_with第一個調用?
def a(obj):
print obj
def b():
a(1)
a(2)
則:
from t import b
with patch('t.a') as m:
b()
m.assert_called_with(1)
我得到:
AssertionError: Expected call: a(1)
Actual call: a(2)