fix: register QueryParams as Mapping for isinstance check
This commit is contained in:
parent
d5e354b448
commit
0493806a3a
@ -12,6 +12,12 @@ from ._urlparse import urlparse
|
||||
__all__ = ["URL", "QueryParams"]
|
||||
|
||||
|
||||
if not typing.TYPE_CHECKING:
|
||||
from collections.abc import Mapping
|
||||
|
||||
Mapping.register(QueryParams)
|
||||
|
||||
|
||||
class URL:
|
||||
"""
|
||||
url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink")
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import typing
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
@ -5,6 +7,13 @@ def hello_world(request: httpx.Request) -> httpx.Response:
|
||||
return httpx.Response(200, text="Hello, world")
|
||||
|
||||
|
||||
def test_queryparams_isinstance_of_mapping():
|
||||
client = httpx.Client(params={"a": "b"})
|
||||
assert isinstance(client.params, httpx.QueryParams)
|
||||
assert isinstance(client.params, typing.Mapping)
|
||||
assert client.params["a"] == "b"
|
||||
|
||||
|
||||
def test_client_queryparams():
|
||||
client = httpx.Client(params={"a": "b"})
|
||||
assert isinstance(client.params, httpx.QueryParams)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user