MCPcopy
hub / github.com/encode/starlette / receive_json

Method receive_json

starlette/testclient.py:197–204  ·  starlette/testclient.py::WebSocketTestSession.receive_json
(self, mode: Literal["text", "binary"] = "text")

Source from the content-addressed store, hash-verified

195 return cast(bytes, message[class="st">"bytes"])
196
197 def receive_json(self, mode: Literal[class="st">"text", class="st">"binary"] = class="st">"text") -> Any:
198 message = self.receive()
199 self._raise_on_close(message)
200 if mode == class="st">"text":
201 text = message[class="st">"text"]
202 else:
203 text = message[class="st">"bytes"].decode(class="st">"utf-8")
204 return json.loads(text)
205
206
207class _TestClientTransport(httpx.BaseTransport):

Callers

nothing calls this directly

Calls 3

receiveMethod · 0.95
_raise_on_closeMethod · 0.95
decodeMethod · 0.80

Tested by

no test coverage detected