MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / test_get_json

Method test_get_json

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

Source from the content-addressed store, hash-verified

1212 assert r.raw_content == b"\xff"
1213
1214 def test_get_json(self):
1215 req = treq(content=None)
1216 with pytest.raises(TypeError):
1217 req.json()
1218
1219 req = treq(content=b"")
1220 with pytest.raises(json.decoder.JSONDecodeError):
1221 req.json()
1222
1223 req = treq(content=b"{}")
1224 assert req.json() == {}
1225
1226 req = treq(content=b'{"a": 1}')
1227 assert req.json() == {"a": 1}
1228
1229 req = treq(content=b"{")
1230
1231 with pytest.raises(json.decoder.JSONDecodeError):
1232 req.json()

Callers

nothing calls this directly

Calls 2

treqFunction · 0.90
jsonMethod · 0.45

Tested by

no test coverage detected