pytest-console-scripts
Pytest plugin for testing console scripts
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8+ and pytest 4.0 or newer.
- Console scripts must be installed (via entry_points or on PATH) before tests run.
- Low friction install with only pytest and importlib-metadata as runtime dependencies.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use this package freely in commercial and open-source projects without restriction.
last release 2023-05-31 (1171 days) · last repo commit 2026-01-09 · 87 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 241,463 downloads/mo, #8,876 on PyPI
Alternatives
Verify before relying
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- 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.
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 on this page. Verify before relying on it.
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
pytest-console-scripts on PyPI
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.
Requires Python 3.8+ and pytest 4.0 or newer. Console scripts must be installed (via entry_points or on PATH) before tests run.
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
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 the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagespytestimportlib-metadata |
| Maintenance | Aging 1,171 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 241,463 / month, #8,876 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaFramework :: 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.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing |
Evidence: pytest_console_scripts-1.4.1-py3-none-any.whl
Tags
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 plugin run console scripts”
- pytest-console-scriptsA pytest plugin that runs Python console scripts within tests,…
- pytest-loggingA pytest plugin that configures Python logging to output to the…
- pytest-xvfbA pytest plugin that automatically runs tests with Xvfb (or…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
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.
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.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
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.
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.
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.
See also pytest-subprocess · pytest-logging · pytest-subtests · pytest-mock · pytest-httpx2 · pytest-grpc · pytest-ansible · subprocess-tee · pytest_httpserver · pytest-freezegun