Skip to content

Commit 9aa3f76

Browse files
committed
Add Call.has_response() helper
1 parent a2f0e48 commit 9aa3f76

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

respx/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def response(self) -> httpx.Response:
5252
raise ValueError(f"{self!r} has no response")
5353
return self.optional_response
5454

55+
def has_response(self) -> bool:
56+
return self.optional_response is not None
57+
5558

5659
class CallList(list, mock.NonCallableMock):
5760
def __init__(self, *args: Sequence[Call], name: Any = "respx") -> None:

tests/test_remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_remote_pass_through(using, client_lib, call_count): # pragma: nocover
3737
assert response.json()["json"] == {"foo": "bar"}
3838

3939
assert respx_mock.calls.last.request.url == url
40-
assert respx_mock.calls.last.response == None # noqa: E711
40+
assert respx_mock.calls.last.has_response() is False
4141

4242
assert route.call_count == call_count
4343
assert respx_mock.calls.call_count == call_count

0 commit comments

Comments
 (0)