asyncly¶
A tiny async HTTP client and a real aiohttp mock server for testing your integrations — built on aiohttp.
asyncly is two small, composable pieces:
-
HTTP client
BaseHttpClient— a thin, typed base class for writing API clients. Map status codes to response handlers, parse into Pydantic / msgspec / JSON, set flexible timeouts, and route through a proxy. -
Mock server
srvmockerruns a realaiohttp.TestServerinside your test loop — not a transport patch. Simulate upstreams, swap responses per test, and assert exactly what your client sent.
Why a real server instead of patching?¶
Transport-patching mocks (aioresponses, respx) are fast but never touch a
socket — they miss real timeouts, header auto-injection, connection handling,
and serialization quirks. asyncly serves a genuine aiohttp server in the same
event loop, so your client exercises the real network stack.
See Testing strategies for the full comparison.
Features¶
- Typed client base with per-status response handlers (JSON, Pydantic, msgspec).
- Real mock server via
start_servicewith dynamic, per-test responses. - Request matching — route by JSON body, headers, or query.
- Assertions on recorded request history.
- Proxy testing — a forwarding mock proxy with
Proxy-Authorizationvalidation. - TLS, msgpack/TOML/YAML responses, and metrics (Prometheus, OpenTelemetry).
- A pytest plugin with ready-made fixtures.
Get started¶
Then jump into the Quickstart.