Skip to content

Randomneo/starlette_async_wstc

Repository files navigation

PyPI version

Starlette Async WebSocket Test Client

Description

Modification of Starlette TestClient to support async calls. Provides async receive*, send* for WebSocketTestSession.

This module is meant to be used with pytest-asyncio.

Installation

pip install starlette_async_wstc

Usage example

from starlette_async_wstc import TestClient
from somwhere import app   # starlette/fastapi app

async def test():
    client = TestClient(app)
    async with client.websocket_connect('/ws') as wsclient:
        await wsclient.send_json({'data': 'test_data'})
        resp = await wsclient.receive_json()
        assert resp == {}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages