MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_make

Method test_make

test/mitmproxy/test_http.py:492–517  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

490 assert repr(response) == "Response(200, no content)"
491
492 def test_make(self):
493 r = Response.make()
494 assert r.status_code == 200
495 assert r.content == b""
496
497 r = Response.make(418, "teatime")
498 assert r.status_code == 418
499 assert r.content == b"teatime"
500 assert r.headers["content-length"] == "7"
501
502 Response.make(content=b"foo")
503 Response.make(content="foo")
504 with pytest.raises(TypeError):
505 Response.make(content=42)
506
507 r = Response.make(headers=[(b"foo", b"bar")])
508 assert r.headers["foo"] == "bar"
509
510 r = Response.make(headers=({"foo": "baz"}))
511 assert r.headers["foo"] == "baz"
512
513 r = Response.make(headers=Headers(foo="qux"))
514 assert r.headers["foo"] == "qux"
515
516 with pytest.raises(TypeError):
517 Response.make(headers=42)
518
519 def test_status_code(self):
520 _test_passthrough_attr(tresp(), "status_code")

Callers

nothing calls this directly

Calls 2

HeadersClass · 0.90
makeMethod · 0.45

Tested by

no test coverage detected