MCPcopy
hub / github.com/urllib3/urllib3 / test_header_repeat

Method test_header_repeat

test/test_collections.py:269–295  ·  view source on GitHub ↗
(self, d: HTTPHeaderDict)

Source from the content-addressed store, hash-verified

267 assert len(d) == 2
268
269 def test_header_repeat(self, d: HTTPHeaderDict) -> None:
270 d["other-header"] = "hello"
271 d.add("other-header", "world")
272
273 assert list(d.items()) == [
274 ("Cookie", "foo"),
275 ("Cookie", "bar"),
276 ("other-header", "hello"),
277 ("other-header", "world"),
278 ]
279
280 d.add("other-header", "!", combine=True)
281 expected_results = [
282 ("Cookie", "foo"),
283 ("Cookie", "bar"),
284 ("other-header", "hello"),
285 ("other-header", "world, !"),
286 ]
287
288 assert list(d.items()) == expected_results
289 # make sure the values persist over copies
290 assert list(d.copy().items()) == expected_results
291
292 other_dict = HTTPHeaderDict()
293 # we also need for extensions to properly maintain results
294 other_dict.extend(d)
295 assert list(other_dict.items()) == expected_results
296
297 def test_extend_from_headerdict(self, d: HTTPHeaderDict) -> None:
298 h = HTTPHeaderDict(Cookie="foo", e="foofoo")

Callers

nothing calls this directly

Calls 5

itemsMethod · 0.95
extendMethod · 0.95
HTTPHeaderDictClass · 0.90
addMethod · 0.80
copyMethod · 0.80

Tested by

no test coverage detected