--- id: pytest-console-scripts version: "1.4.1" license: MIT license_treatment: permissive maintenance: aging --- # pytest-console-scripts — Pytest plugin for testing console scripts License: permissive · Maintenance: aging · Downloads: 241.5K/mo ## What it is and what it does pytest-console-scripts is a pytest plugin that lets you test Python console scripts as if they were being run from the command line. It provides a `script_runner` fixture that captures output and return codes, and offers two execution modes: in-process (where the script runs in the same Python interpreter as pytest, speeding up test suites) and subprocess (where the script runs in a fresh interpreter, simulating real-world invocation more closely). You can run scripts installed via console_scripts entry points, standalone Python files, or executables on the PATH. The plugin supports configuring execution mode globally via pytest config, per-test via command-line flags, or per-test via pytest markers. In-process mode enables mocking of script internals, while subprocess mode validates that scripts work correctly when invoked independently. Use it for: - Test CLI tools and console scripts installed via setup.py entry_points during development. - Validate that scripts behave identically when run in-process (fast) and subprocess (realistic) modes. - Capture and assert on stdout, stderr, and return codes from Python scripts in test suites. - Mock functions inside console scripts during in-process test runs to isolate behavior. - Speed up test iteration by running scripts in-process, then verify with subprocess mode in CI. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that runs Python console scripts within tests, supporting both in-process execution (fast iteration) and subprocess mode (realistic testing). Yes, if you maintain Python CLI tools or console scripts and want to test them within pytest. The dual execution mode (in-process for speed, subprocess for realism) is a genuine advantage over subprocess.run() alone. However, note that the package is aging—last release was May 2023 with no recent commits—so verify compatibility with your pytest version before adopting. No known security vulnerabilities. ## Install pip install pytest-console-scripts uv add pytest-console-scripts poetry add pytest-console-scripts ## Installing pytest-console-scripts Before you install: Low friction install with only pytest and importlib-metadata as runtime dependencies. Maintenance status is aging—last release was 2023-05-31 and the repository shows no recent activity, though it remains unarchived. License in practice: MIT license is permissive; you can use this package freely in commercial and open-source projects without restriction. Quickstart: pip install pytest-console-scripts from pytest_console_scripts import ScriptRunner def test_script(script_runner: ScriptRunner): result = script_runner.run(['my-script', '--version']) assert result.returncode == 0 Requires Python 3.8+ and pytest 4.0 or newer. Console scripts must be installed (via entry_points or on PATH) before tests run. Verify before relying: - Whether the aging maintenance status (last release May 2023) affects compatibility with recent pytest versions. - Current test coverage and whether the package is actively maintained despite unarchived status. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 241.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest plugin run console scripts, test python scripts subprocess, pytest script runner fixture, in-process script execution testing, console entry point testing, cli-testing, script-runner, pytest-plugin [View on SkillFed](https://skillfed.io/packages/pytest-console-scripts) · [View on PyPI](https://pypi.org/project/pytest-console-scripts/)