Skip to main content

A tiny plugin for pytest which runs PostgreSQL in Docker

Project description

To speed up tests, pytest-pg does the following tweaks:

  1. fsync=off
  2. full_page_writes=off
  3. synchronous_commit=off
  4. jit=off
  5. bgwriter_lru_maxpages=0
  6. data directory is mounted to a tmpfs

How to use?

import asyncpg


async def test_asyncpg_query(pg):
    conn = await asyncpg.connect(
        user=pg.user,
        password=pg.password,
        database=pg.database,
        host=pg.host,
        port=pg.port,
    )

    await conn.execute("CREATE TABLE test_table (id serial PRIMARY KEY, value text);")
    await conn.execute("INSERT INTO test_table (value) VALUES ($1)", "hello")
    row = await conn.fetchrow("SELECT value FROM test_table WHERE id = $1", 1)

    assert row["value"] == "hello"

    await conn.close()

v0.0.25 (2025-05-18)

  • Add pg_17 fixture

v0.0.24 (2025-05-11)

v0.0.23 (2025-04-11)

v0.0.22 (2025-04-03)

  • Override docker host with env variable

v0.0.17 (2024-04-03)

  • Override docker host with env variable

v0.0.15 (2023-05-04)

v0.0.14 (2022-09-19)

  • Disable jit by default
  • Set bgwriter_lru_maxpages

v0.0.12 (2022-01-18)

  • Ditch logging because it seems to be useless

v0.0.11 (2022-01-09)

  • Move volume to tmpfs

v0.0.10 (2022-01-08)

  • Volumes used to remain after running test consuming disk space

v0.0.9 (2021-12-28)

  • Disable fsync, full_page_writes, synchronous_commit to speedup the tests

v0.0.8 (2021-12-26)

  • Add typing marker, mypy. Run tests in CI

v0.0.7 (2021-12-25)

  • Fix is_ready based on psycopg2

v0.0.6 (2021-12-25)

  • Add all recent major versions of PG

v0.0.4 (2021-12-10)

  • Fix is_postgres_ready usage

v0.0.3 (2021-12-10)

  • Fix uuid generation

v0.0.2 (2021-12-10)

  • Follow pytest guide for plugins

v0.0.1 (2021-12-10)

  • A first version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_pg-0.0.25.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

pytest_pg-0.0.25-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest_pg-0.0.25.tar.gz.

File metadata

  • Download URL: pytest_pg-0.0.25.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pytest_pg-0.0.25.tar.gz
Algorithm Hash digest
SHA256 36fb20692ae22e43bd21ad1004848515849a2a1292528700d67e166e6e67a751
MD5 9256651c5b6abac61f86bca5ab86c6b1
BLAKE2b-256 ada59f6e6e55c803063d9e0ad0080fd323a1a1acb72d9c92a3af98444ef41b2e

See more details on using hashes here.

File details

Details for the file pytest_pg-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: pytest_pg-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pytest_pg-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 a00e3f4b3bfbe807c9c1a61da904caf9a93cb98d9f71b32dce4ea762ed16ac7d
MD5 065c2fddb08a5fd0b1e2a75e4c1d7a04
BLAKE2b-256 1c54d37d034852e52263f93490af91e6a6649b62ba872a07e0207d852b0baca8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page