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

Function test_queryparams

tests/test_datastructures.py:344–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

342
343
344def test_queryparams() -> None:
345 q = QueryParams("a=123&a=456&b=789")
346 assert "a" in q
347 assert "A" not in q
348 assert "c" not in q
349 assert q["a"] == "456"
350 assert q.get("a") == "456"
351 assert q.get("nope", None) is None
352 assert q.getlist("a") == ["123", "456"]
353 assert list(q.keys()) == ["a", "b"]
354 assert list(q.values()) == ["456", "789"]
355 assert list(q.items()) == [("a", "456"), ("b", "789")]
356 assert len(q) == 2
357 assert list(q) == ["a", "b"]
358 assert dict(q) == {"a": "456", "b": "789"}
359 assert str(q) == "a=123&a=456&b=789"
360 assert repr(q) == "QueryParams('a=123&a=456&b=789')"
361 assert QueryParams({"a": "123", "b": "456"}) == QueryParams([("a", "123"), ("b", "456")])
362 assert QueryParams({"a": "123", "b": "456"}) == QueryParams("a=123&b=456")
363 assert QueryParams({"a": "123", "b": "456"}) == QueryParams({"b": "456", "a": "123"})
364 assert QueryParams() == QueryParams({})
365 assert QueryParams([("a", "123"), ("a", "456")]) == QueryParams("a=123&a=456")
366 assert QueryParams({"a": "123", "b": "456"}) != "invalid"
367
368 q = QueryParams([("a", "123"), ("a", "456")])
369 assert QueryParams(q) == q
370
371
372@pytest.mark.anyio

Callers

nothing calls this directly

Calls 6

QueryParamsClass · 0.90
getMethod · 0.45
getlistMethod · 0.45
keysMethod · 0.45
valuesMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected