testgres is a testing utility for PostgreSQL and its extensions, providing a simple API to manage temporary PostgreSQL instances, create databases, execute queries, and test replication. Current version 1.13.7, PyPI release with monthly cadence.
Install & Compatibility
Where this runs
tested against v1.14.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.390s · 22.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.5s · import 0.372s · 23MB
21MB installed
● package 21MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Direct import of the module; no submodule import needed.
import testgres
Quickstart demonstrating starting a temporary PostgreSQL node, initializing, starting, creating a database, and executing a query.
import testgres
def test_postgres():
# Start a temporary PostgreSQL instance
with testgres.get_new_node('test_node') as node:
node.init()
node.start()
# Create a database and execute a query
db = node.execute('CREATE DATABASE testdb')
result = node.execute('SELECT 1')
print(result)
# Node is automatically stopped and cleaned up
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.