Right now if a user wants to assert call arguments for multiple calls in specific order, the only option is to use has_calls method:
>>> from chainmock.mock import call
>>> mocker(Teapot).mock("add_tea").has_calls([call("oolong"), call("black")])
<chainmock._api.Assert object at ...>
>>> Teapot().add_tea("oolong")
>>> Teapot().add_tea("black")
I see these problems with this approach:
- Use caller needs to know all the calls beforehand and new calls can't be easily added afterwards.
- There is no way to use this with
match_args_* methods.
- Using
call type is a bit cumbersome.
Proposal
- Add new methods:
awaited_with
called_with
match_args_await
match_args_call
- Assert call args in the order the methods are called.
The above code could be rewritten as follows:
>>> mocker(Teapot).mock("add_tea").called_with("oolong").called_with("black")
<chainmock._api.Assert object at ...>
>>> Teapot().add_tea("oolong")
>>> Teapot().add_tea("black")
Right now if a user wants to assert call arguments for multiple calls in specific order, the only option is to use
has_callsmethod:I see these problems with this approach:
match_args_*methods.calltype is a bit cumbersome.Proposal
awaited_withcalled_withmatch_args_awaitmatch_args_callThe above code could be rewritten as follows: