testgres
Testing utility for PostgreSQL and its extensions
Decision gist · record as of 2026-08-14
Yes, if you need to test PostgreSQL-dependent code in isolation. The package is actively maintained, has no known vulnerabilities, and low install friction. The main caveat is the unclear PostgreSQL license treatment—verify it aligns with your project's licensing before committing. The blocker is a working PostgreSQL installation; if you already have one, testgres is a straightforward way to automate cluster provisioning in tests.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PostgreSQL binaries (initdb, pg_ctl, psql) in PATH or accessible via PG_CONFIG or PG_BIN environment variable; supports Python 3.7.3 and newer.
- Low install friction with a pure-Python wheel and six runtime dependencies.
- Active maintenance with a release 10 days ago and commits through August 2026; the project has 157 stars and no known vulnerabilities.
License · maintenance · safety
PostgreSQL (unclear) — Licensed under PostgreSQL (license_treatment: unclear). The PostgreSQL license is permissive but differs from common open-source licenses; verify compatibility with your project's licensing requirements before adopting.
last release 2026-08-04 (10 days) · last repo commit 2026-08-04 · 157 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 101,216 downloads/mo, #12,953 on PyPI
Alternatives
Verify before relying
pip install testgres
import testgres
with testgres.get_new_node() as node:
node.init()
node.start()
result = node.execute('select 1')
print(result)- Whether the PostgreSQL license (license_treatment: unclear) is compatible with your project's licensing model.
- Performance characteristics when running many parallel test nodes (documentation mentions pytest-xdist but does not quantify overhead).
What it is and what it does
testgres is a test utility that spins up isolated, temporary PostgreSQL clusters for use in Python test suites. It handles the full lifecycle—initialization, startup, query execution, and cleanup—so tests can focus on logic rather than database provisioning. The package wraps PostgreSQL command-line tools (initdb, pg_ctl, psql) and provides Python bindings for common operations like executing queries, managing transactions, creating backups, spawning replicas, and running pgbench benchmarks.
It integrates with pytest via fixtures and the standard Python logging module, making it straightforward to aggregate logs from multiple test nodes. The package supports both local and remote (Linux-only) node provisioning via SSH, and provides sensible configuration defaults that can be customized. With six runtime dependencies (pg8000, port-for, six, psutil, packaging, and testgres.os_ops) and low install friction, it is designed to be dropped into existing test suites with minimal setup overhead.
Use it for
- Run integration tests against a fresh PostgreSQL instance that is created, used, and destroyed within a single test function or fixture.
- Test PostgreSQL extensions or custom configurations by provisioning nodes with specific postgresql.conf settings via default_conf() and append_conf().
- Verify replication and backup workflows by creating a master node, taking backups, spawning replicas, and asserting catchup behavior.
- Execute quick performance benchmarks using pgbench through testgres in a controlled, repeatable test environment.
- Parallelize test suites across multiple isolated PostgreSQL nodes using pytest-xdist, with each node on a distinct port.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to test PostgreSQL-dependent code in isolation.
The package is actively maintained, has no known vulnerabilities, and low install friction. The main caveat is the unclear PostgreSQL license treatment—verify it aligns with your project's licensing before committing. The blocker is a working PostgreSQL installation; if you already have one, testgres is a straightforward way to automate cluster provisioning in tests.
Install
testgres on PyPI
Before you install
Low install friction with a pure-Python wheel and six runtime dependencies. Active maintenance with a release 10 days ago and commits through August 2026; the project has 157 stars and no known vulnerabilities.
Requires PostgreSQL binaries (initdb, pg_ctl, psql) in PATH or accessible via PG_CONFIG or PG_BIN environment variable; supports Python 3.7.3 and newer.
License in practice
Licensed under PostgreSQL (license_treatment: unclear). The PostgreSQL license is permissive but differs from common open-source licenses; verify compatibility with your project's licensing requirements before adopting.
Quickstart
pip install testgres
import testgres
with testgres.get_new_node() as node:
node.init()
node.start()
result = node.execute('select 1')
print(result)
Verify before relying
- Whether the PostgreSQL license (license_treatment: unclear) is compatible with your project's licensing model.
- Performance characteristics when running many parallel test nodes (documentation mentions pytest-xdist but does not quantify overhead).
Package facts
| License | PostgreSQL unclear |
| Python support | Supports the current Python release >=3.7.3 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 6 packagespg8000port-forsixpsutilpackagingtestgres.os_ops |
| Maintenance | Actively maintained 10 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 101,216 / month, #12,953 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersOperating System :: UnixProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: Testing |
Evidence: testgres-1.15.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “postgresql test cluster setup”
- testgrestestgres orchestrates temporary PostgreSQL clusters for Python tests,…
- patroniPatroni orchestrates PostgreSQL high-availability clusters using…
- testing.postgresqlAutomatically creates and tears down temporary PostgreSQL instances…
Give your agent the search over MCP, or paste the wish link into any chat.
More Libraries packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Provides parsing, arithmetic, and recurrence rule computation for dates and times, with timezone support and iCalendar RFC compliance.
Install it if you need to parse flexible date strings, compute relative dates, handle timezones, or work with recurrence rules—it's the de facto choice for these tasks.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
See also testing.postgresql · pytest-pgsql · pytest-postgresql · postgres · testing.common.database · patroni · pgdb · testcontainers-postgres · py-pglite · pgserver