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
Traceback (most recent call last):
File "...", line 8, in <module>
respx.get(url=url).respond()
File ".../python3.9/site-packages/respx/api.py", line 74, in get
return mock.get(url, name=name, **lookups)
File ".../python3.9/site-packages/respx/router.py", line 174, in get
return self.request(method="GET", url=url, name=name, **lookups)
File ".../python3.9/site-packages/respx/router.py", line 165, in request
return self.route(method=method, url=url, name=name, **lookups)
File ".../python3.9/site-packages/respx/router.py", line 132, in route
route = Route(*patterns, **lookups)
File ".../python3.9/site-packages/respx/models.py", line 119, in __init__
self._pattern = M(*patterns, **lookups)
File ".../python3.9/site-packages/respx/patterns.py", line 544, in M
extras = parse_url_patterns(value)
File ".../python3.9/site-packages/respx/patterns.py", line 648, in parse_url_patterns
bases[Path.key] = Path(url.path, lookup=lookup)
File ".../python3.9/site-packages/respx/patterns.py", line 92, in __init__
self.value = self.clean(value)
File ".../python3.9/site-packages/respx/patterns.py", line 417, in clean
value = httpx.URL(path).path
File ".../python3.9/site-packages/httpx/_urls.py", line 113, in __init__
self._uri_reference = urlparse(url, **kwargs)
File ".../python3.9/site-packages/httpx/_urlparse.py", line 160, in urlparse
raise InvalidURL("Invalid non-printable ASCII character in URL")
httpx.InvalidURL: Invalid non-printable ASCII character in URL
I could reproduce this problem only with the url pattern, the following works fine:
Looking at the stack trace, it's seems to be a httpx"bug". I don't think we should try to fix this in respx, but rather open an httpx issue and hopefully it gets fixed there, and then automatically gets supported in respx.
RESPX attempts to initialize it with the unquoted path (which is indeed an invalid URL in this case), while httpx.URL seems to work correctly with the quoted version of the URL.
Hey!
I have faced a bug during an attempt to use respx with hypothesis to mock autogenerated URLs when encoded special symbols are present in the url path.
This code fails with the
AllMockedAssertionError
:This code fails with
httpx.InvalidURL
:Full traceback:
I could reproduce this problem only with the
url
pattern, the following works fine:Versions:
The text was updated successfully, but these errors were encountered: