Skip to main content

alembic-gauntlet

Testing toolkit for Alembic migrations — run your migrations through the gauntlet

PyPI Python License CI codecov Docs

Installation

pip install "alembic-gauntlet[asyncio]"

The asyncio extra installs pytest-asyncio, which is not optional in practice: the inherited tests and both async fixtures are plain async def, so a suite without it errors out instead of running. It also has to be in auto mode:

# pyproject.toml
[tool.pytest.ini_options]
asyncio_mode = "auto"

Requirements: Python 3.10+, PostgreSQL, and an async driver such as asyncpg

Quick start

import pytest
from alembic_gauntlet import MigrationTestBase
from sqlalchemy import MetaData
from myapp.db import Base


@pytest.mark.integration
class TestMyMigrations(MigrationTestBase):
    """All seven tests inherited automatically."""

    @pytest.fixture
    def orm_metadata(self) -> MetaData:
        return Base.metadata

    @pytest.fixture(scope="session")
    def migration_db_url(self) -> str:
        return "postgresql+asyncpg://user:pass@localhost/testdb"

That's it! You now have:

  • test_stairway_upgrade_downgrade — each migration forward and back
  • test_migrations_up_to_date — schema matches ORM models
  • test_check_constraints_match — CHECK constraints match ORM models, by name
  • test_enum_values_match — enum values match ORM models, in order
  • test_single_head_revision — no unmerged branches
  • test_downgrade_all_the_way — full downgrade to base
  • test_naming_conventions — indexes and FKs follow conventions

Documentation

Full documentation at bedrock-python.github.io/alembic-gauntlet.

  • For AI agents — the whole library on one page, written for a coding assistant.

License

Apache 2.0 — see LICENSE.

Metadata

Release files for alembic-gauntlet 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alembic-gauntlet 0.3.1
File Size Uploaded
alembic_gauntlet-0.3.1.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alembic-gauntlet 0.3.1
File Interpreter ABI Platform
alembic_gauntlet-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 51.1 kB

Release files / alembic_gauntlet-0.3.1.tar.gz

Download URL alembic_gauntlet-0.3.1.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a31ff62290ec7b2ff653c2d90999796687c4e0f131b1e609f60bdb1d1df05aac
BLAKE2b-256 checksum
How to use checksums
c75d85a67e58a7f998b06bfa90f2c4a152291d5de633bbd92ed3bbb640993da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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 / alembic_gauntlet-0.3.1-py3-none-any.whl

Download URL alembic_gauntlet-0.3.1-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c529409a01f23a775b36ea9e64507f036678db6c06230e21aa68d14a5a59cb8
BLAKE2b-256 checksum
How to use checksums
188e196ac862bf708558936dd8b9378a95f4d5009c06f04d0a6e9768784dc3f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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 history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page