Skip to main content

Modification of Starlette TestClient to support async calls

Project description

PyPI version

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.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: starlette_async_wstc-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 135e333dfed2eb20f8a760c88ee06cf8179117db6cda39b7d32a226f1a7e05b1
MD5 343c21f17ac99ac2ddf55aa4ac7565e8
BLAKE2b-256 da04d0768074496fc3696f91f8d11a7d1762e3e142d6e5e5323ad28f31ba9d32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for starlette_async_wstc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc88b8a32060069f394056c99975e2216dfbc7dacf4db1ac961ccec108382d78
MD5 da41493bd91dea5cc2dfde2cc5cb25d0
BLAKE2b-256 ebcdcdb2a7594a69a0252cebb17b7d27adfef54f14629c67977e019a4e8eaca9

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