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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file starlette_async_wstc-0.1.2.tar.gz.

File metadata

  • Download URL: starlette_async_wstc-0.1.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for starlette_async_wstc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 68eb6717b60c381af0ce7aab4995321ae0b78ecef2b85f405f7813ce28405748
MD5 4c619f890d6a1ed9c65cd012b59c736d
BLAKE2b-256 0331fb5a1f19df4cdbc27b2c3c01d4fd83350840874a1e078682d423d0814a1f

See more details on using hashes here.

File details

Details for the file starlette_async_wstc-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for starlette_async_wstc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f4216e034ebe72d5e7df284cbc003d17461c2edba3c6f19ed1d4c449ee04af52
MD5 d0ee1a0e2a7b5e6e83d216fa17429732
BLAKE2b-256 7f949fd5f98c1a80973562f13064410ed762fb2e90ad6bf77cb2a48b476c7640

See more details on using hashes here.

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