Skip to main content

Modification of Starlette TestClient to support async calls

Project description

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 == {}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starlette_async_wstc-0.1.2.tar.gz (17.0 kB view hashes)

Uploaded Source

Built Distribution

starlette_async_wstc-0.1.2-py3-none-any.whl (17.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page