Testing
In-process ASGI test clients for unit and integration tests.
TestClient
python
class TestClient(app: Any)Synchronous-friendly test client for •LaurenApp.
TestClient.arequest
python
def arequest(self, method: str, url: str, kwargs: Any = {}) -> TestResponseTestClient.request
python
def request(self, method: str, url: str, kwargs: Any = {}) -> TestResponseTestClient.get
python
def get(self, url: str, kw: Any = {}) -> TestResponseTestClient.post
python
def post(self, url: str, kw: Any = {}) -> TestResponseTestClient.put
python
def put(self, url: str, kw: Any = {}) -> TestResponseTestClient.delete
python
def delete(self, url: str, kw: Any = {}) -> TestResponseTestClient.patch
python
def patch(self, url: str, kw: Any = {}) -> TestResponseTestClient.options
python
def options(self, url: str, kw: Any = {}) -> TestResponseTestClient.head
python
def head(self, url: str, kw: Any = {}) -> TestResponseWsTestClient
python
class WsTestClient(app: Any)Factory for •WebSocketTestSession bound to an ASGI app.
Mirrors the ergonomic pattern of •TestClient — one client
instance per app, one •WebSocketTestSession per connection.
Use as::
python
client = WsTestClient(app)
async with client.connect("/chat/42", headers={...}) as ws:
...WsTestClient.connect
python
def connect(self, path: str, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, subprotocols: Iterable[str] | None = None, query_string: str = '') -> WebSocketTestSession