test_queryparams.py
This file
Path
tests/models/test_queryparams.py
92 lines · 2.4 KiB · Python
Last changed by
Version 0.15.0 (#1301)Tom Christiebefore adoptionf932af9
History of this fileTake it
The walk stopped after 200 commits: lines older than 5cf1acc point at it.
Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 1–2why, one step back1import pytest2Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 3why, one step back3import httpxAdd docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 4–14why, one step back456@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 back15 q = httpx.QueryParams(source)Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 16–21why, one step back16 assert "a" in q17 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 NoneConsistent multidict methods (#1089)Tom Christiebefore adoption2ba9c1e
line 22why, one step back22 assert q.get_list("a") == ["123", "456"]Use get_list consistently (#1119)Tom Christiebefore adoptione5f8743
line 23why, one step back23Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 24–31why, one step back24 assert list(q.keys()) == ["a", "b"]25 assert list(q.values()) == ["456", "789"]26 assert list(q.items()) == [("a", "456"), ("b", "789")]27 assert len(q) == 228 assert list(q) == ["a", "b"]29 assert dict(q) == {"a": "456", "b": "789"}30 assert str(q) == "a=123&a=456&b=789"31 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 32why, one step back32 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 33–34why, one step back33 [("a", "123"), ("b", "456")]34 )Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 35–38why, one step back35 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(36 "a=123&b=456"37 )38 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 39–40why, one step back39 {"b": "456", "a": "123"}40 )Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 41–45why, one step back41 assert httpx.QueryParams() == httpx.QueryParams({})42 assert httpx.QueryParams([("a", "123"), ("a", "456")]) == httpx.QueryParams(43 "a=123&a=456"44 )45 assert httpx.QueryParams({"a": "123", "b": "456"}) != "invalid"Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
line 46why, one step back46Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 47–48why, one step back47 q = httpx.QueryParams([("a", "123"), ("a", "456")])48 assert httpx.QueryParams(q) == qAdd docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 49–51why, one step back495051def test_queryparam_types():Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 52why, one step back52 q = httpx.QueryParams(None)Support QueryParams(None) (#1060)Tom Christiebefore adoptionff93a01
lines 53–54why, one step back53 assert str(q) == ""54Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 55why, one step back55 q = httpx.QueryParams({"a": True})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 56–57why, one step back56 assert str(q) == "a=true"57Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 58why, one step back58 q = httpx.QueryParams({"a": False})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 59–60why, one step back59 assert str(q) == "a=false"60Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 61why, one step back61 q = httpx.QueryParams({"a": ""})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 62–63why, one step back62 assert str(q) == "a="63Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 64why, one step back64 q = httpx.QueryParams({"a": None})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 65–66why, one step back65 assert str(q) == "a="66Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 67why, one step back67 q = httpx.QueryParams({"a": 1.23})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 68–69why, one step back68 assert str(q) == "a=1.23"69Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 70why, one step back70 q = httpx.QueryParams({"a": 123})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 71–72why, one step back71 assert str(q) == "a=123"72Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 73why, one step back73 q = httpx.QueryParams({"a": [1, 2]})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 74–77why, one step back74 assert str(q) == "a=1&a=2"757677def test_queryparam_setters():Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 78why, one step back78 q = httpx.QueryParams({"a": 1})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 79–82why, one step back79 q.update([])8081 assert str(q) == "a=1"82Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 83why, one step back83 q = httpx.QueryParams([("a", 1), ("a", 2)])Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 84–86why, one step back84 q["a"] = "3"85 assert str(q) == "a=3"86Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 87–88why, one step back87 q = httpx.QueryParams([("a", 1), ("b", 1)])88 u = httpx.QueryParams([("b", 2), ("b", 3)])Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 89–92why, one step back89 q.update(u)9091 assert str(q) == "a=1&b=2&b=3"92 assert q["b"] == u["b"]