$npx skillfedfor your agent

pytest-mock-resources

A pytest plugin for easily instantiating reproducible mock resources.

With conditionsPyPI TestingReleased Sep 2025312.4K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_mock_resources-2.12.4-py3-none-any.whl
v2.12.4 · released 2025-09-17 · Python <4,>=3.7 · 4 runtime deps: pytest, sqlalchemy, typing_extensions, importlib-metadata

Yes, if you write integration tests for code that queries databases or interacts with services. The low install friction, active maintenance, permissive license, and absence of known vulnerabilities make it a solid choice. The Docker requirement is a real constraint for some environments, but for standard development and CI setups it is straightforward. Use it when mocking database calls is insufficient and you need to test actual query logic.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Docker must be installed and running (or accessible via remote Docker) for database fixtures other than SQLite.
  • Requires Python 3.7 or later.
  • Low friction installation with a pure-Python wheel.

License · maintenance · safety

MIT (permissive) — MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.

last release 2025-09-17 (331 days) · last repo commit 2026-05-14 · 205 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 312,380 downloads/mo, #7,725 on PyPI

Verify before relying

pip install pytest-mock-resources

from pytest_mock_resources import create_postgres_fixture

pg = create_postgres_fixture(session=True)

def test_query(pg):
    pg.add(User(name='Alice'))
    pg.flush()
    result = pg.query(User).all()
    assert len(result) == 1
  • Whether async fixture support works with all database backends or only specific ones.
  • Performance characteristics when running many tests with container lifecycle overhead.
  • Compatibility with CI/CD environments that restrict Docker access.
  • Whether pre-population via 'actions' is supported for all resource types.
Same gist for agents: .md · .json

What it is and what it does

pytest-mock-resources is a pytest plugin that manages the lifecycle of containerized databases and services for testing. Instead of mocking database calls or maintaining a shared test database, it spins up isolated real instances (PostgreSQL, MySQL, Redis, MongoDB, SQLite, Redshift, Moto) in Docker containers, tears them down after each test, and provides them as pytest fixtures. This lets you write tests that execute actual queries against a real schema, catching bugs that mocks would miss—like incorrect joins, N+1 queries, or schema mismatches—while keeping tests isolated and reproducible across machines.

The package assumes you're using pytest and have Docker available. It handles container startup, teardown, and provides a session object (for SQL databases via sqlalchemy) or client (for NoSQL/cache stores) that you inject into your test functions. It supports both synchronous and async fixtures, making it suitable for modern async test suites.

Use it for

  • Test sqlalchemy ORM queries with real joins and eager loading to verify query correctness before deployment.
  • Validate data access layers against actual PostgreSQL or MySQL schemas without mocking database calls.
  • Test Redis or MongoDB integration code with real container instances that reflect production behavior.
  • Run integration tests in CI/CD pipelines where each test gets a fresh, isolated database state.
  • Develop tests for Redshift-specific features like COPY/UNLOAD commands using a compatible fixture.
  • Catch N+1 query problems and lazy-loading bugs that mock-based tests would not surface.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you write integration tests for code that queries databases or interacts with services.

The low install friction, active maintenance, permissive license, and absence of known vulnerabilities make it a solid choice. The Docker requirement is a real constraint for some environments, but for standard development and CI setups it is straightforward. Use it when mocking database calls is insufficient and you need to test actual query logic.

Install

pytest-mock-resources on PyPI

Before you install

Low friction installation with a pure-Python wheel. Maintenance is active with a recent release and ongoing commits. Core dependencies are lightweight (pytest, sqlalchemy, typing_extensions, importlib-metadata), though Docker availability is required for most fixtures beyond SQLite.

Docker must be installed and running (or accessible via remote Docker) for database fixtures other than SQLite. Requires Python 3.7 or later.

License in practice

MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install pytest-mock-resources

from pytest_mock_resources import create_postgres_fixture

pg = create_postgres_fixture(session=True)

def test_query(pg):
    pg.add(User(name='Alice'))
    pg.flush()
    result = pg.query(User).all()
    assert len(result) == 1

Verify before relying

  • Whether async fixture support works with all database backends or only specific ones.
  • Performance characteristics when running many tests with container lifecycle overhead.
  • Compatibility with CI/CD environments that restrict Docker access.
  • Whether pre-population via 'actions' is supported for all resource types.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release <4,>=3.7
Install frictionLow. Pure-Python wheel
Runtime dependencies
4 packages
pytestsqlalchemytyping_extensionsimportlib-metadata
MaintenanceActively maintained 331 days since the last release
Last repo commit
First released
Downloads312,380 / month, #7,725 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone 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.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Evidence: pytest_mock_resources-2.12.4-py3-none-any.whl

Tags

Capabilities
pytest database fixturesdocker-based test resourcesintegration testing with real databasespytest postgres fixturemock database for testingcontainerized test resourcespytest sqlalchemy testing
Topics
pytest-pluginintegration-testingdocker-fixtures
PyPI keywords
pytestsqlalchemydockerfixturemock

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 › “docker-based test resources”

  • pytest-mock-resourcesProvides pytest fixtures that spin up real database and service…
  • pytest-docker-toolsProvides pytest fixture factories for declaratively defining…
  • localstackLocalStack is a command-line tool that emulates AWS cloud services…

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

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.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

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.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

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.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

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.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

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.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also pytest-databases · pytest-docker-tools · pytest-redis · pytest-pgsql · mock-alchemy · pytest-mysql · pytest-container · pytest-postgresql · pytest-shutil · pytest-grpc