MCPcopy
hub / github.com/encode/httpx / test_queryparams

Function test_queryparams

tests/models/test_queryparams.py:16–50  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

14 ],
15)
16def test_queryparams(source):
17 q = httpx.QueryParams(source)
18 assert "a" in q
19 assert "A" not in q
20 assert "c" not in q
21 assert q["a"] == "123"
22 assert q.get("a") == "123"
23 assert q.get("nope", default=None) is None
24 assert q.get_list("a") == ["123", "456"]
25
26 assert list(q.keys()) == ["a", "b"]
27 assert list(q.values()) == ["123", "789"]
28 assert list(q.items()) == [("a", "123"), ("b", "789")]
29 assert len(q) == 2
30 assert list(q) == ["a", "b"]
31 assert dict(q) == {"a": "123", "b": "789"}
32 assert str(q) == "a=123&a=456&b=789"
33 assert repr(q) == "QueryParams('a=123&a=456&b=789')"
34 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(
35 [("a", "123"), ("b", "456")]
36 )
37 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(
38 "a=123&b=456"
39 )
40 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(
41 {"b": "456", "a": "123"}
42 )
43 assert httpx.QueryParams() == httpx.QueryParams({})
44 assert httpx.QueryParams([("a", "123"), ("a", "456")]) == httpx.QueryParams(
45 "a=123&a=456"
46 )
47 assert httpx.QueryParams({"a": "123", "b": "456"}) != "invalid"
48
49 q = httpx.QueryParams([("a", "123"), ("a", "456")])
50 assert httpx.QueryParams(q) == q
51
52
53def test_queryparam_types():

Callers

nothing calls this directly

Calls 5

getMethod · 0.95
get_listMethod · 0.95
keysMethod · 0.95
valuesMethod · 0.95
itemsMethod · 0.95

Tested by

no test coverage detected