Skip to content
Myr

test_queryparams.py

This file

Path

tests/models/test_queryparams.py

64 lines · 1.8 KiB · Python

Last changed by

Get test suite back to ~100% line coverage (#406)Seth Michael Larsonbefore adoption05f5dc2

History of this file

Take it

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

Renaming -> httpx (#129)Tom Christiebefore adoption2d09d5b

line 1why, one step back
1from httpx import QueryParams

Sync or Async dispatch (#83)Tom Christiebefore adoption0cbf3c7

lines 2–33why, one step back
2
34def test_queryparams():5 q = QueryParams("a=123&a=456&b=789")6 assert "a" in q7 assert "A" not in q8 assert "c" not in q9 assert q["a"] == "456"10 assert q.get("a") == "456"11 assert q.get("nope", default=None) is None12 assert q.getlist("a") == ["123", "456"]13 assert list(q.keys()) == ["a", "b"]14 assert list(q.values()) == ["456", "789"]15 assert list(q.items()) == [("a", "456"), ("b", "789")]16 assert len(q) == 217 assert list(q) == ["a", "b"]18 assert dict(q) == {"a": "456", "b": "789"}19 assert str(q) == "a=123&a=456&b=789"20 assert repr(q) == "QueryParams('a=123&a=456&b=789')"21 assert QueryParams({"a": "123", "b": "456"}) == QueryParams(22 [("a", "123"), ("b", "456")]23 )24 assert QueryParams({"a": "123", "b": "456"}) == QueryParams("a=123&b=456")25 assert QueryParams({"a": "123", "b": "456"}) == QueryParams(26 {"b": "456", "a": "123"}27 )28 assert QueryParams() == QueryParams({})29 assert QueryParams([("a", "123"), ("a", "456")]) == QueryParams("a=123&a=456")30 assert QueryParams({"a": "123", "b": "456"}) != "invalid"3132 q = QueryParams([("a", "123"), ("a", "456")])33 assert QueryParams(q) == q

Tweak query param types (#175)Tom Christiebefore adoption66754ad

lines 34–53why, one step back
34
3536def test_queryparam_types():37 q = QueryParams({"a": True})38 assert str(q) == "a=true"3940 q = QueryParams({"a": False})41 assert str(q) == "a=false"4243 q = QueryParams({"a": ""})44 assert str(q) == "a="4546 q = QueryParams({"a": None})47 assert str(q) == "a="4849 q = QueryParams({"a": 1.23})50 assert str(q) == "a=1.23"5152 q = QueryParams({"a": 123})53 assert str(q) == "a=123"

Get test suite back to ~100% line coverage (#406)Seth Michael Larsonbefore adoption05f5dc2

lines 54–64why, one step back
54
5556def test_queryparam_setters():57 q = QueryParams({"a": 1})58 q.update([])5960 assert str(q) == "a=1"6162 q = QueryParams([("a", 1), ("a", 2)])63 q["a"] = "3"64 assert str(q) == "a=3"