You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, assert_any_call doesn't check the request body, only the params. Sometimes we want to check the request body. We cannot use assert_called_with because the request we want to check is not the last one. We tried an implementation locally, and it works:
defassert_any_call_with(
self,
url: "Union[URL, str, Pattern]",
method: str=hdrs.METH_GET,
*args: Any,
**kwargs: Any
):
"""assert the mock has been called with the specified arguments. The assert passes if the mock has *ever* been called, unlike `assert_called_with` and `assert_called_once_with` that only pass if the call is the most recent one."""url=normalize_url(merge_params(url, kwargs.get("params")))
method=method.upper()
key= (method, url)
try:
request_list=self.requests[key]
exceptKeyError:
expected_string=self._format_call_signature(
url, method=method, *args, **kwargs
)
raiseAssertionError("%s call not found"%expected_string)
else:
expected=self._build_request_call(method, *args, **kwargs)
found=Falseforactualinrequest_list:
ifexpected==actual:
found=Truebreakifnotfound:
expected_string=self._format_call_signature(
url, method=method, *args, **kwargs
)
raiseAssertionError("%s call not found"%expected_string)
If assert_any_call_with is useful, we'd love to create a PR.
The text was updated successfully, but these errors were encountered:
Currently,
assert_any_call
doesn't check the request body, only the params. Sometimes we want to check the request body. We cannot useassert_called_with
because the request we want to check is not the last one. We tried an implementation locally, and it works:If
assert_any_call_with
is useful, we'd love to create a PR.The text was updated successfully, but these errors were encountered: