MCPcopy
hub / github.com/scrapy/scrapy / test_setdefault

Method test_setdefault

tests/test_http_headers.py:74–84  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

72 assert "Content-Type" not in h
73
74 def test_setdefault(self):
75 h = Headers()
76 hlist = ["ip1", "ip2"]
77 olist = h.setdefault("X-Forwarded-For", hlist)
78 assert h.getlist("X-Forwarded-For") is not hlist
79 assert h.getlist("X-Forwarded-For") is olist
80
81 h = Headers()
82 olist = h.setdefault("X-Forwarded-For", "ip1")
83 assert h.getlist("X-Forwarded-For") == [b"ip1"]
84 assert h.getlist("X-Forwarded-For") is olist
85
86 def test_iterables(self):
87 idict = {"Content-Type": "text/html", "X-Forwarded-For": ["ip1", "ip2"]}

Callers

nothing calls this directly

Calls 3

getlistMethod · 0.95
HeadersClass · 0.90
setdefaultMethod · 0.45

Tested by

no test coverage detected