Asyncpg Recorder
Installation
uv add asyncpg-recorder
Usage
import asyncpg
from asyncpg_recorder import use_cassette
async def query():
con = await asyncpg.connect(DSN)
res = await con.fetch("SELECT NOW();")
await con.close()
return res
@use_cassette
def test_select_now_replay():
query()
When using pytest parametrized fixtures put the @use_cassette decorator on the test function not the fixture:
import asyncpg
from asyncpg_recorder import use_cassette
import pytest
import pytest_asyncio
@pytest_asyncio.fixture(params=[False, True])
async def param(request):
return request.param
@pytest.mark.asyncio
@pytest.mark.usefixtures("param")
@use_cassette
async def test_parametrized_fixtures(path):
async def query():
con = await asyncpg.connect(DSN)
res = await con.fetch("SELECT NOW();")
await con.close()
return res
await select_version()
If you want to save the cassettes in a specific directory, set the variable cassettes-dir in your pyproject.toml. The path should be relative to pyproject.toml.
[tool.asyncpg-recorder]
"cassettes-dir"="tests/cassettes"
Caveats
The same database request on Python >= 3.14 yields a different hash for cassette entry than on Python <= 3.13. If it is important to run tests against both Python version ranges you need to record twice.
Development
uv run prek install # pre-commit
uv run pytest
Release
This project uses SemVer.
To make a new release run ./scripts/release.sh <version number>.
Limitation
- Works only with pytest
- Depends on testcontainers
- Testcontainers is used to boot up a temporary Postgres instance to which asyncpg will be connected.
- This slows test suite down.
Metadata
Release files for asyncpg-recorder 0.11.0
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 |
|---|---|---|---|---|
| asyncpg_recorder-0.11.0.tar.gz | 20.3 kB | Without provenance | Details for asyncpg_recorder-0.11.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asyncpg_recorder-0.11.0-py3-none-any.whl | Python 3 | none | any | Details for asyncpg_recorder-0.11.0-py3-none-any.whl |
Total release size: 42.0 kB
Release files / asyncpg_recorder-0.11.0.tar.gz
| Download URL | asyncpg_recorder-0.11.0.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73b4e9e6a6abc0953a531fb80537c239b347f69ea20df3ec997e321c26c20de6
|
|
BLAKE2b-256 checksum How to use checksums |
c7f4cb3cc9cd91eaeae18b5ad33a0f8b1c71a55232f136223b34e6510e8b4399
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / asyncpg_recorder-0.11.0-py3-none-any.whl
| Download URL | asyncpg_recorder-0.11.0-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bdaaae4c1d4dba97aaf786720ba3f5905a558f30ece1f80b70d2a3e902386b62
|
|
BLAKE2b-256 checksum How to use checksums |
6f92546b28bae49513b53b41b588cd820fe1c0d6aca3b0dfc4f4d50c01477b9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for asyncpg-recorder 0.11.0
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.