All Projects → vinissimus → async-asgi-testclient

vinissimus / async-asgi-testclient

Licence: MIT license
A framework-agnostic library for testing ASGI web applications

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to async-asgi-testclient

serverless-mangum-examples
Example ASGI applications and Serverless Framework configurations using Mangum
Stars: ✭ 26 (-78.86%)
Mutual labels:  asgi, quart, starlette
msgpack-asgi
Drop-in MessagePack support for ASGI applications and frameworks
Stars: ✭ 100 (-18.7%)
Mutual labels:  asgi, starlette
fastapi-zeit-now
A simple example of deploying FastAPI as a Zeit Serverless Function
Stars: ✭ 24 (-80.49%)
Mutual labels:  asgi, starlette
starlette-graphene3
An ASGI app for using Graphene v3 with Starlette / FastAPI
Stars: ✭ 52 (-57.72%)
Mutual labels:  asgi, starlette
spectree
API spec validator and OpenAPI document generator for Python web frameworks.
Stars: ✭ 190 (+54.47%)
Mutual labels:  asgi, starlette
starlite
Light, Flexible and Extensible ASGI API framework
Stars: ✭ 1,525 (+1139.84%)
Mutual labels:  asgi, starlette
inboard
🚢 Docker images and utilities to power your Python APIs and help you ship faster. With support for Uvicorn, Gunicorn, Starlette, and FastAPI.
Stars: ✭ 106 (-13.82%)
Mutual labels:  asgi, starlette
webargs-starlette
Declarative request parsing and validation for Starlette with webargs
Stars: ✭ 36 (-70.73%)
Mutual labels:  asgi, starlette
arel
Lightweight browser hot reload for Python ASGI web apps
Stars: ✭ 69 (-43.9%)
Mutual labels:  asgi, starlette
mongox
Familiar async Python MongoDB ODM
Stars: ✭ 113 (-8.13%)
Mutual labels:  asgi, starlette
nardis
A small web framework based on ASGI
Stars: ✭ 14 (-88.62%)
Mutual labels:  asgi
aioprometheus
A Prometheus Python client library for asyncio-based applications
Stars: ✭ 114 (-7.32%)
Mutual labels:  asgi
Sanic
Async Python 3.7+ web server/framework | Build fast. Run fast.
Stars: ✭ 15,660 (+12631.71%)
Mutual labels:  asgi
fastAPI-aiohttp-example
How to use and test fastAPI with an aiohttp client
Stars: ✭ 69 (-43.9%)
Mutual labels:  asgi
Datasette
An open source multi-tool for exploring and publishing data
Stars: ✭ 5,640 (+4485.37%)
Mutual labels:  asgi
json-head
JSON microservice for performing HEAD requests
Stars: ✭ 31 (-74.8%)
Mutual labels:  asgi
Uvicorn
The lightning-fast ASGI server. 🦄
Stars: ✭ 4,676 (+3701.63%)
Mutual labels:  asgi
geiss
An protocol server for django channels 1 written in go
Stars: ✭ 27 (-78.05%)
Mutual labels:  asgi
starlette-context
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.
Stars: ✭ 320 (+160.16%)
Mutual labels:  starlette
hypercorn-fastapi-docker
Docker image with Hypercorn for FastAPI apps in Python 3.7, 3.8, 3.9. Ready for HTTP2 and HTTPS
Stars: ✭ 18 (-85.37%)
Mutual labels:  asgi

async-asgi-testclient

Build Status PyPI version Codcov

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].