$npx skillfedfor your agent

pytest-subprocess

A plugin to fake subprocess for pytest

Worth itPyPI TestingReleased May 2026514.9K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_subprocess-1.6.0-py3-none-any.whl
v1.6.0 · released 2026-05-10 · Python >=3.6 · 1 runtime deps: pytest

Yes. This is a mature, actively maintained plugin with no security issues, low install friction, and a permissive license. It directly solves the common testing problem of isolating code that calls external processes. Install it if your test suite includes code that uses subprocess.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low friction install with a single runtime dependency (pytest).
  • The package is actively maintained with a recent release and no known vulnerabilities, making it straightforward to add to test suites.

License · maintenance · safety

MIT (permissive) — MIT license is permissive, allowing use in commercial and open-source projects with minimal restrictions—just include the license text.

last release 2026-05-10 (96 days) · last repo commit 2026-05-26 · 117 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 514,874 downloads/mo, #6,237 on PyPI

Verify before relying

pip install pytest-subprocess

import subprocess

def test_example(fp):
    fp.register(["echo", "hello"], stdout="hello")
    result = subprocess.run(["echo", "hello"], capture_output=True, text=True)
    assert result.stdout == "hello"
  • Whether the plugin works with subprocess.Popen subclasses or only the standard library implementation
  • Performance overhead when registering many subprocess calls in a single test suite
Same gist for agents: .md · .json

What it is and what it does

pytest-subprocess is a pytest plugin that intercepts calls to subprocess.Popen and its higher-level wrappers (subprocess.run, subprocess.call, subprocess.check_call, subprocess.check_output) to replace them with fake implementations. Instead of executing real system commands during tests, you register expected commands and their outputs using the fp fixture, which then returns those outputs when your code calls subprocess. This eliminates test dependencies on external tools, makes tests faster and more reliable, and lets you simulate error conditions and edge cases that would be hard to trigger with real processes.

The plugin supports registering different outputs for repeated calls to the same command, passing input to stdin with custom handling logic, allowing unregistered commands to fall through to real subprocess execution, and using callbacks to inject custom behavior. It works across all subprocess functions because they all ultimately call Popen internally. The fixture is available both as fp and the longer form fake_process.

Use it for

  • Test code that shells out to git, docker, or other CLI tools without requiring those tools to be installed or available in CI
  • Simulate subprocess failures and non-zero exit codes to verify error handling paths in your application
  • Mock multi-step command sequences where each call returns different output, testing state-dependent subprocess behavior
  • Verify that your code passes the correct arguments and environment to subprocess without actually executing them
  • Test subprocess input/output handling by registering stdin callbacks that transform input into output

Worth the install?

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

Worth it

Yes.

This is a mature, actively maintained plugin with no security issues, low install friction, and a permissive license. It directly solves the common testing problem of isolating code that calls external processes. Install it if your test suite includes code that uses subprocess.

Install

pytest-subprocess on PyPI

Before you install

Low friction install with a single runtime dependency (pytest). The package is actively maintained with a recent release and no known vulnerabilities, making it straightforward to add to test suites.

License in practice

MIT license is permissive, allowing use in commercial and open-source projects with minimal restrictions—just include the license text.

Quickstart

pip install pytest-subprocess

import subprocess

def test_example(fp):
    fp.register(["echo", "hello"], stdout="hello")
    result = subprocess.run(["echo", "hello"], capture_output=True, text=True)
    assert result.stdout == "hello"

Verify before relying

  • Whether the plugin works with subprocess.Popen subclasses or only the standard library implementation
  • Performance overhead when registering many subprocess calls in a single test suite

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.6
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
pytest
MaintenanceActively maintained 96 days since the last release
Last repo commit
First released
Downloads514,874 / month, #6,237 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 :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing

Evidence: pytest_subprocess-1.6.0-py3-none-any.whl

Tags

Capabilities
mock subprocess calls in testsfake subprocess for pytesttest code that runs external commandspytest subprocess mockingintercept subprocess.Popenregister fake process outputunit test subprocess without real execution
Topics
subprocess-mockingtest-isolation

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 › “mock subprocess calls in tests”

  • pytest-subprocessPytest plugin that intercepts and fakes subprocess calls, allowing…
  • testfixturesTestfixtures provides helpers and mock objects for writing unit and…
  • requests-mockIntercepts and mocks HTTP requests made through the requests library,…

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-console-scripts · pytest-forked · pytest-responses · EasyProcess · scripttest · pytest-mock · pytest-depends · pytest_httpserver · pytest-httpx2 · pytest-reportportal