Skip to content
Myr

test_queryparams.py

This file

Path

tests/models/test_queryparams.py

95 lines · 2.5 KiB · Python

Last changed by

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

History of this file

Take it

The walk stopped after 200 commits: lines older than ae45c23 point at it.

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 1–2why, one step back
1import pytest
2

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 3why, one step back
3import httpx

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 4–14why, one step back
4
56@pytest.mark.parametrize(7 "source",8 [9 "a=123&a=456&b=789",10 {"a": ["123", "456"], "b": 789},11 {"a": ("123", "456"), "b": 789},12 ],13)14def test_queryparams(source):

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 15why, one step back
15 q = httpx.QueryParams(source)

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 16–21why, one step back
16 assert "a" in q
17 assert "A" not in q18 assert "c" not in q19 assert q["a"] == "456"20 assert q.get("a") == "456"21 assert q.get("nope", default=None) is None

Consistent multidict methods (#1089)Tom Christiebefore adoption2ba9c1e

line 22why, one step back
22 assert q.get_list("a") == ["123", "456"]

Use get_list consistently (#1119)Tom Christiebefore adoptione5f8743

lines 23–26why, one step back
23
24 with pytest.warns(DeprecationWarning):25 assert q.getlist("a") == ["123", "456"]26

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 27–34why, one step back
27 assert list(q.keys()) == ["a", "b"]
28 assert list(q.values()) == ["456", "789"]29 assert list(q.items()) == [("a", "456"), ("b", "789")]30 assert len(q) == 231 assert list(q) == ["a", "b"]32 assert dict(q) == {"a": "456", "b": "789"}33 assert str(q) == "a=123&a=456&b=789"34 assert repr(q) == "QueryParams('a=123&a=456&b=789')"

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 35why, one step back
35 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 36–37why, one step back
36 [("a", "123"), ("b", "456")]
37 )

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 38–41why, one step back
38 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(
39 "a=123&b=456"40 )41 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 42–43why, one step back
42 {"b": "456", "a": "123"}
43 )

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 44–48why, one step back
44 assert httpx.QueryParams() == httpx.QueryParams({})
45 assert httpx.QueryParams([("a", "123"), ("a", "456")]) == httpx.QueryParams(46 "a=123&a=456"47 )48 assert httpx.QueryParams({"a": "123", "b": "456"}) != "invalid"

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

line 49why, one step back
49

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 50–51why, one step back
50 q = httpx.QueryParams([("a", "123"), ("a", "456")])
51 assert httpx.QueryParams(q) == q

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 52–54why, one step back
52
5354def test_queryparam_types():

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 55why, one step back
55 q = httpx.QueryParams(None)

Support QueryParams(None) (#1060)Tom Christiebefore adoptionff93a01

lines 56–57why, one step back
56 assert str(q) == ""
57

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 58why, one step back
58 q = httpx.QueryParams({"a": True})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 59–60why, one step back
59 assert str(q) == "a=true"
60

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 61why, one step back
61 q = httpx.QueryParams({"a": False})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 62–63why, one step back
62 assert str(q) == "a=false"
63

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 64why, one step back
64 q = httpx.QueryParams({"a": ""})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 65–66why, one step back
65 assert str(q) == "a="
66

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 67why, one step back
67 q = httpx.QueryParams({"a": None})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 68–69why, one step back
68 assert str(q) == "a="
69

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 70why, one step back
70 q = httpx.QueryParams({"a": 1.23})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 71–72why, one step back
71 assert str(q) == "a=1.23"
72

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 73why, one step back
73 q = httpx.QueryParams({"a": 123})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 74–75why, one step back
74 assert str(q) == "a=123"
75

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 76why, one step back
76 q = httpx.QueryParams({"a": [1, 2]})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 77–80why, one step back
77 assert str(q) == "a=1&a=2"
787980def test_queryparam_setters():

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 81why, one step back
81 q = httpx.QueryParams({"a": 1})

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 82–85why, one step back
82 q.update([])
8384 assert str(q) == "a=1"85

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

line 86why, one step back
86 q = httpx.QueryParams([("a", 1), ("a", 2)])

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 87–89why, one step back
87 q["a"] = "3"
88 assert str(q) == "a=3"89

Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205

lines 90–91why, one step back
90 q = httpx.QueryParams([("a", 1), ("b", 1)])
91 u = httpx.QueryParams([("b", 2), ("b", 3)])

Do not mark wheel as universal (#851)Tom Christiebefore adoptionae45c23

lines 92–95why, one step back
92 q.update(u)
9394 assert str(q) == "a=1&b=2&b=3"95 assert q["b"] == u["b"]