diff --git a/docs/test_client.md b/docs/test_client.md index 13ed2336..1c28a8de 100644 --- a/docs/test_client.md +++ b/docs/test_client.md @@ -3,7 +3,8 @@ The test client allows you to make requests against your ASGI application, using the `requests` library. ```python -from starlette import HTMLResponse, TestClient +from starlette.response import HTMLResponse +from starlette.testclient import TestClient class App: @@ -51,7 +52,7 @@ class App: def test_app(): client = TestClient(App) - with client.wsconnect('/') as session: + with client.websocket_connect('/') as session: data = session.receive_text() assert data == 'Hello, world!' ``` @@ -65,10 +66,16 @@ always raised by the test client. #### Establishing a test session -* `.wsconnect(url, subprotocols=None, **options)` - Takes the same set of arguments as `requests.get()`. +* `.websocket_connect(url, subprotocols=None, **options)` - Takes the same set of arguments as `requests.get()`. May raise `starlette.websockets.Disconnect` if the application does not accept the websocket connection. +#### Sending data + +* `.send_text(data)` - Send the given text to the application. +* `.send_bytes(data)` - Send the given bytes to the application. +* `.send_json(data)` - Send the given data to the application. + #### Receiving data * `.receive_text()` - Wait for incoming text sent by the application and return it.