$npx skillfedfor your agent

pytest-stub

Stub packages, modules and attributes.

With conditionsPyPI TestingReleased Apr 202094.8K downloads / moBSD 3-Clause LicensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_stub-1.1.0-py2.py3-none-any.whl
v1.1.0 · released 2020-04-28

Yes, if you need to test code with external dependencies you don't want to install—the plugin is simple and has no runtime dependencies. However, maintenance is abandoned (last release 2020-04-28), so compatibility with Python versions beyond 3.8 is unverified and you should test it in your environment first. For active projects, consider whether a maintained alternative or manual mocking would be more reliable long-term.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires pytest >= 2.9.0 and Python 3.6 or later.
  • Low install friction with no runtime dependencies.
  • Maintenance is inactive—last release was 2020-04-28 and the repository shows no recent activity—so you should expect no bug fixes or updates for new Python versions beyond those already listed.

License · maintenance · safety

BSD 3-Clause License (permissive) — BSD 3-Clause License is permissive and imposes minimal restrictions; you can use this package freely in commercial and private projects with only attribution required.

last release 2020-04-28 (2299 days) · last repo commit 2020-04-28 · 9 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 94,774 downloads/mo, #13,307 on PyPI

Verify before relying

# Install
pip install pytest-stub

# In your test file
def test_example(stub):
    stub.apply({
        'django.core.management.call_command': '[func]',
        'cv2': '[mock]',
    })
  • Whether the package works reliably with Python versions newer than 3.8 (last tested version in classifiers).
  • Whether auto-generated stubs ([func], [cls], [mock], [mock_persist]) behave correctly for complex dependency signatures.
  • Current compatibility with modern pytest versions and whether any breaking changes have occurred since 2020.
Same gist for agents: .md · .json

What it is and what it does

pytest-stub is a pytest plugin that intercepts imports and replaces external dependencies with stubs—either auto-generated placeholders (functions, classes, mocks) or custom objects you provide. This lets you test code that depends on heavy or unavailable libraries (like OpenCV, Django, or NumPy) without installing them, which is useful when testing a library that uses those dependencies but you want to isolate your test environment.

The plugin works via a `stub` fixture in individual tests or a global `stub_global()` function in conftest.py. You pass a dictionary mapping import paths to stub types: `'[func]'` generates a function, `'[cls]'` generates a class, `'[mock]'` generates a MagicMock, and `'[mock_persist]'` generates a persistent mock. You can also provide custom objects directly. The stubs are applied before test execution so imports succeed without the actual dependency present.

Use it for

  • Test a library that depends on OpenCV or NumPy without installing those heavy packages in your CI environment.
  • Isolate tests of Django-related code by stubbing django.core.management and django.conf modules.
  • Verify that your code handles missing or unavailable dependencies gracefully without actually removing them.
  • Speed up test runs by replacing slow-to-import or slow-to-initialize external libraries with lightweight stubs.
  • Test code paths that use optional dependencies without requiring those dependencies to be installed.

Worth the install?

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

With conditions

Yes, if you need to test code with external dependencies you don't want to install—the plugin is simple and has no runtime dependencies.

However, maintenance is abandoned (last release 2020-04-28), so compatibility with Python versions beyond 3.8 is unverified and you should test it in your environment first. For active projects, consider whether a maintained alternative or manual mocking would be more reliable long-term.

Install

pytest-stub on PyPI

Before you install

Low install friction with no runtime dependencies. Maintenance is inactive—last release was 2020-04-28 and the repository shows no recent activity—so you should expect no bug fixes or updates for new Python versions beyond those already listed.

Requires pytest >= 2.9.0 and Python 3.6 or later.

License in practice

BSD 3-Clause License is permissive and imposes minimal restrictions; you can use this package freely in commercial and private projects with only attribution required.

Quickstart

# Install
pip install pytest-stub

# In your test file
def test_example(stub):
    stub.apply({
        'django.core.management.call_command': '[func]',
        'cv2': '[mock]',
    })

Verify before relying

  • Whether the package works reliably with Python versions newer than 3.8 (last tested version in classifiers).
  • Whether auto-generated stubs ([func], [cls], [mock], [mock_persist]) behave correctly for complex dependency signatures.
  • Current compatibility with modern pytest versions and whether any breaking changes have occurred since 2020.

Package facts

LicenseBSD 3-Clause License permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceAbandoned 2,299 days since the last release
Last repo commit
First released
Downloads94,774 / month, #13,307 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: Testing

Evidence: pytest_stub-1.1.0-py2.py3-none-any.whl

Tags

Capabilities
pytest dependency stubbingmock external packages in testsstub modules pytesttest without dependenciespytest fixture stubsreplace imports in testspytest mock packages
Topics
pytest-plugintest-isolationdependency-mocking

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 › “pytest dependency stubbing”

  • pytest-stubA pytest plugin that replaces package, module, and attribute…
  • aresponsesMocks external HTTP/HTTPS services for asyncio-based tests by…
  • mockitoMockito is a spying and stubbing framework for Python that lets you…

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-mock · stubs · flexmock · mockito · pretend · types-mock · pytest-sftpserver · pip-install-test · pytest-subprocess · pytest-faker