When using the files parameter in a helper (http) function, both str and io.BytesIO payloads are not deemed equal and raise an error.
Input
str payload
@respx.mock
def test_file_str_payload():
FILE_DATA = {"upload": ("image/png", "str", "image/png")}
respx.patch("https://api.example.com/endpoint/123", files=FILE_DATA)
httpx.patch("https://api.example.com/endpoint/123", files=FILE_DATA)
io.BytesIO payload
@respx.mock
def test_file_bytesio_payload():
FILE_DATA = {
"upload": ("image/png", io.BytesIO(b"some image content"), "image/png")
}
respx.patch("https://api.example.com/endpoint/123", files=FILE_DATA)
httpx.patch("https://api.example.com/endpoint/123", files=FILE_DATA)
Output
Error raised
raise AllMockedAssertionError(f"RESPX: {request!r} not mocked!")
respx.models.AllMockedAssertionError: RESPX: <Request('PATCH', 'https://api.example.com/endpoint/123')> not mocked!
When using the
filesparameter in a helper (http) function, bothstrandio.BytesIOpayloads are not deemed equal and raise an error.Input
strpayloadio.BytesIOpayloadOutput
Error raised