pytest-alembic
A pytest plugin for verifying alembic migrations.
Decision gist · record as of 2026-08-14
Yes. This package solves a real class of production bugs (broken migrations, merge conflicts, forgotten migrations) with low install friction and active maintenance. If you use alembic and SQLAlchemy, the built-in tests alone provide immediate value in CI. The custom test fixtures add flexibility for complex migrations. No known vulnerabilities, permissive license, and steady releases since 2020 make it a safe, practical choice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires an existing alembic migration environment configured in your project; pytest-alembic integrates with it rather than setting it up from scratch.
- Low friction: pure Python wheel with three well-established runtime dependencies (pytest, alembic, sqlalchemy).
- Active maintenance with a recent commit on 2026-07-27 and steady release history since 2020-04-02.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use this package freely in commercial and open-source projects with minimal restrictions.
last release 2025-05-27 (444 days) · last repo commit 2026-07-27 · 250 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,284,731 downloads/mo, #4,111 on PyPI
Alternatives
Verify before relying
pip install pytest-alembic
# In your project with alembic migrations configured:
pytest --test-alembic
# Or write a custom test:
from pytest_alembic import alembic_runner
def test_my_migration(alembic_runner):
alembic_runner.migrate_up_before('revision_id')
# ... setup data ...
alembic_runner.migrate_up_one()- Whether the built-in tests (single_head_revision, upgrade, model_definitions_match_ddl, up_down_consistency) run automatically or require explicit configuration.
- Exact setup boilerplate required beyond standard alembic initialization.
- Whether experimental tests (all_models_register_on_metadata, downgrade_leaves_no_trace) are stable enough for production use.
What it is and what it does
pytest-alembic is a pytest plugin that automates testing of alembic database migrations. It provides four built-in tests that catch common migration mistakes: ensuring a single head revision exists (no diverged history), verifying the full upgrade path works, confirming migrations match your SQLAlchemy model definitions, and validating that downgrades succeed. Beyond these defaults, it offers fixtures like `alembic_runner` to write custom tests for complex data migrations, letting you practice test-driven development on tricky migration logic before running against production.
The plugin sits between pytest and your alembic environment, running migrations in a test database and asserting their correctness. It solves real problems: catching forgotten migrations before merge, detecting migration failures with existing data, and preventing broken deployments from conflicting migrations merged in parallel. Most projects need minimal setup beyond what alembic itself requires.
Use it for
- Catch forgotten migrations in CI before they reach production by asserting model definitions match the migration history.
- Test complex data migrations with custom logic using the alembic_runner fixture to set up state and verify outcomes.
- Detect diverged migration histories from merge conflicts automatically rather than discovering them during deployment.
- Validate that all migrations can be reversed cleanly, ensuring your database can roll back if needed.
- Ensure all SQLAlchemy models are properly imported and registered so autogenerate captures the full schema.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This package solves a real class of production bugs (broken migrations, merge conflicts, forgotten migrations) with low install friction and active maintenance. If you use alembic and SQLAlchemy, the built-in tests alone provide immediate value in CI. The custom test fixtures add flexibility for complex migrations. No known vulnerabilities, permissive license, and steady releases since 2020 make it a safe, practical choice.
Install
pytest-alembic on PyPI
Before you install
Low friction: pure Python wheel with three well-established runtime dependencies (pytest, alembic, sqlalchemy). Active maintenance with a recent commit on 2026-07-27 and steady release history since 2020-04-02.
Requires an existing alembic migration environment configured in your project; pytest-alembic integrates with it rather than setting it up from scratch.
License in practice
MIT license is permissive; you can use this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install pytest-alembic
# In your project with alembic migrations configured:
pytest --test-alembic
# Or write a custom test:
from pytest_alembic import alembic_runner
def test_my_migration(alembic_runner):
alembic_runner.migrate_up_before('revision_id')
# ... setup data ...
alembic_runner.migrate_up_one()
Verify before relying
- Whether the built-in tests (single_head_revision, upgrade, model_definitions_match_ddl, up_down_consistency) run automatically or require explicit configuration.
- Exact setup boilerplate required beyond standard alembic initialization.
- Whether experimental tests (all_models_register_on_metadata, downgrade_leaves_no_trace) are stable enough for production use.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4,>=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagespytestalembicsqlalchemy |
| Maintenance | Actively maintained 444 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,284,731 / month, #4,111 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Framework :: PytestLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9 |
Evidence: pytest_alembic-0.12.1-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 › “test alembic migrations”
- pytest-alembicA pytest plugin that runs built-in and custom tests against alembic…
- alembicAlembic generates and manages database schema migrations for…
- alembic-postgresql-enumExtends Alembic to automatically detect and manage PostgreSQL enum…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
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.
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.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also alembic · django-test-migrations · Flask-Alembic · alembic-autogenerate-enums · alembic_utils · alembic-postgresql-enum · aerich · Flask-Migrate · pytest-mysql · starrocks