{"categories":[{"label":"Testing","url":"https://skillfed.io/packages/category/software-development-testing/3"}],"enrichment":{"capability":"Pytest plugin that intercepts and fakes subprocess calls, allowing you to register mock process outputs and behaviors without executing real commands.","skillfed_tags":["subprocess-mocking","test-isolation"],"use_cases":["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"],"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.\n\nThe 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.","worth_installing":"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."},"id":"pytest-subprocess","links":{"html":"https://skillfed.io/packages/pytest-subprocess","md":"https://skillfed.io/packages/pytest-subprocess.md","pypi":"https://pypi.org/project/pytest-subprocess/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2026-05-10","license_spdx":null,"license_treatment":"permissive","name":"pytest-subprocess","python_support":"supports_current","summary":"A plugin to fake subprocess for pytest"},"popularity":{"monthly_downloads":514874,"position":6237,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"1.6.0"}
