Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions respx/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,33 @@ class MultiItemsMixin:
value: Any

def _multi_items(
self, value: Any, *, parse_any: bool = False
self, value: Any, *, parse_any: bool = False, encode_any: bool = False
) -> Tuple[Tuple[str, Tuple[Any, ...]], ...]:
return tuple(
(
key,
tuple(
ANY if parse_any and v == str(ANY) else v
(
ANY
if parse_any and v == str(ANY)
else str(ANY)
if encode_any and v == ANY
else v
)
for v in value.get_list(key)
),
)
for key in sorted(value.keys())
)

def __hash__(self):
return hash((self.__class__, self.lookup, self._multi_items(self.value)))
return hash(
(
self.__class__,
self.lookup,
self._multi_items(self.value, encode_any=True),
)
)

def _eq(self, value: Any) -> Match:
value_items = self._multi_items(self.value, parse_any=True)
Expand Down
1 change: 1 addition & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def test_files_post_body():
with respx.mock:
url = "https://foo.bar/"
file = ("file", ("filename.txt", b"...", "text/plain", {"X-Foo": "bar"}))
respx.post(url + "other", files={"file": mock.ANY}) # Non-matching ANY
route = respx.post(url, files={"file": mock.ANY}) % 201
response = httpx.post(url, files=[file])
assert response.status_code == 201
Expand Down
Loading