async-asgi-testclient
Async ASGI TestClient is a library for testing web applications that implements ASGI specification (version 2 and 3).
The motivation behind this project is building a common testing library that doesn't depend on the web framework (Quart, Startlette, ...).
It works by calling the ASGI app directly. This avoids the need to run the app with a http server in a different process/thread/asyncio-loop. Since the app and test run in the same asyncio loop, it's easier to write tests and debug code.
This library is based on the testing module provided in Quart.
Quickstart
Requirements: Python 3.6+
Installation:
pip install async-asgi-testclient
Usage
my_api.py:
from quart import Quart, jsonify
app = Quart(__name__)
@app.route("/")
async def root():
return "plain response"
@app.route("/json")
async def json():
return jsonify({"hello": "world"})
if __name__ == '__main__':
app.run()
test_app.py:
from async_asgi_testclient import TestClient
import pytest
@pytest.mark.asyncio
async def test_quart_app():
from .my_api import app
async with TestClient(app) as client:
resp = await client.get("/")
assert resp.status_code == 200
assert resp.text == "plain response"
resp = await client.get("/json")
assert resp.status_code == 200
assert resp.json() == {"hello": "world"}
Supports
- cookies
- multipart/form-data
- follow redirects
- response streams
- request streams
- websocket support
Metadata
Release files for async-asgi-testclient 1.4.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| async-asgi-testclient-1.4.11.tar.gz | 11.7 kB | Without provenance | Details for async-asgi-testclient-1.4.11.tar.gz |
Release files / async-asgi-testclient-1.4.11.tar.gz
| Download URL | async-asgi-testclient-1.4.11.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4449ac85d512d661998ec61f91c9ae01851639611d748d81ae7f816736551792
|
|
BLAKE2b-256 checksum How to use checksums |
529a0eb3fd37d4f9ad1e9b2b6d6b91357d3ebf7534271c32e343185a5d204903
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
|
Security for async-asgi-testclient 1.4.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.