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 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
lines 23–26why, one step back2324 with pytest.warns(DeprecationWarning):25 assert q.getlist("a") == ["123", "456"]26Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 27–34why, one step back27 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 back35 assert httpx.QueryParams({"a": "123", "b": "456"}) == httpx.QueryParams(Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 36–37why, one step back36 [("a", "123"), ("b", "456")]37 )Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 38–41why, one step back38 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(Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 42–43why, one step back42 {"b": "456", "a": "123"}43 )Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 44–48why, one step back44 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"Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
line 49why, one step back49Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 50–51why, one step back50 q = httpx.QueryParams([("a", "123"), ("a", "456")])51 assert httpx.QueryParams(q) == qAdd docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 52–54why, one step back525354def test_queryparam_types():Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 55why, one step back55 q = httpx.QueryParams(None)Support QueryParams(None) (#1060)Tom Christiebefore adoptionff93a01
lines 56–57why, one step back56 assert str(q) == ""57Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 58why, one step back58 q = httpx.QueryParams({"a": True})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 59–60why, one step back59 assert str(q) == "a=true"60Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 61why, one step back61 q = httpx.QueryParams({"a": False})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 62–63why, one step back62 assert str(q) == "a=false"63Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 64why, one step back64 q = httpx.QueryParams({"a": ""})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": None})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 68–69why, one step back68 assert str(q) == "a="69Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 70why, one step back70 q = httpx.QueryParams({"a": 1.23})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 71–72why, one step back71 assert str(q) == "a=1.23"72Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 73why, one step back73 q = httpx.QueryParams({"a": 123})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 74–75why, one step back74 assert str(q) == "a=123"75Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 76why, one step back76 q = httpx.QueryParams({"a": [1, 2]})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 77–80why, one step back77 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 back81 q = httpx.QueryParams({"a": 1})Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 82–85why, one step back82 q.update([])8384 assert str(q) == "a=1"85Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
line 86why, one step back86 q = httpx.QueryParams([("a", 1), ("a", 2)])Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 87–89why, one step back87 q["a"] = "3"88 assert str(q) == "a=3"89Better test case consistency. Prefer `import httpx` and `httpx.Client`. (#1222)Tom Christiebefore adoption28c7205
lines 90–91why, one step back90 q = httpx.QueryParams([("a", 1), ("b", 1)])91 u = httpx.QueryParams([("b", 2), ("b", 3)])Add docs on request instances to Requests compatibility guide (#823)Srikanth Chekuribefore adoption5cf1acc
lines 92–95why, one step back92 q.update(u)9394 assert str(q) == "a=1&b=2&b=3"95 assert q["b"] == u["b"]