MCPcopy Index your code
hub / github.com/encode/starlette / test_headers

Function test_headers

tests/test_datastructures.py:226–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

224
225
226def test_headers() -> None:
227 h = Headers(raw=[(b"a", b"123"), (b"a", b"456"), (b"b", b"789")])
228 assert "a" in h
229 assert "A" in h
230 assert "b" in h
231 assert "B" in h
232 assert "c" not in h
233 assert h["a"] == "123"
234 assert h.get("a") == "123"
235 assert h.get("nope", None) is None
236 assert h.getlist("a") == ["123", "456"]
237 assert h.keys() == ["a", "a", "b"]
238 assert h.values() == ["123", "456", "789"]
239 assert h.items() == [("a", "123"), ("a", "456"), ("b", "789")]
240 assert list(h) == ["a", "a", "b"]
241 assert dict(h) == {"a": "123", "b": "789"}
242 assert repr(h) == "Headers(raw=[(b'a', b'123'), (b'a', b'456'), (b'b', b'789')])"
243 assert h == Headers(raw=[(b"a", b"123"), (b"b", b"789"), (b"a", b"456")])
244 assert h != [(b"a", b"123"), (b"A", b"456"), (b"b", b"789")]
245
246 h = Headers({"a": "123", "b": "789"})
247 assert h["A"] == "123"
248 assert h["B"] == "789"
249 assert h.raw == [(b"a", b"123"), (b"b", b"789")]
250 assert repr(h) == "Headers({'a': '123', 'b': '789'})"
251
252
253def test_mutable_headers() -> None:

Callers

nothing calls this directly

Calls 6

getlistMethod · 0.95
keysMethod · 0.95
valuesMethod · 0.95
itemsMethod · 0.95
HeadersClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected