pytest-shutil
A goodie-bag of unix shell and environment tools for py.test
What it is and what it does
pytest-shutil is a collection of pytest fixtures and helper functions designed to simplify testing of shell scripts, command-line tools, and code that interacts with the filesystem or environment. It centers on a workspace fixture—a function-scoped temporary directory with convenience methods for running commands and managing files—plus utilities for controlling environment variables, changing directories, managing umasks, and executing subprocesses with output capture and coverage integration.
The package wraps common Unix testing patterns into reusable pytest fixtures and context managers, reducing boilerplate in test suites that need to spawn processes, manipulate the environment, or work with temporary file hierarchies. It depends on pytest, six, execnet, termcolor, and importlib-metadata, and targets Python 3.6 and later.
Use it for:
- Test shell scripts or command-line tools by running them in isolated workspaces and capturing their output.
- Verify code behavior under different environment variable configurations using set_env and unset_env context managers.
- Run Python functions or modules as if they were entry points, useful for testing CLI entry points or subprocess isolation.
- Manage temporary directories with automatic cleanup in test fixtures, avoiding manual tempfile boilerplate.
- Execute subprocesses with coverage instrumentation to measure test coverage of spawned processes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides pytest fixtures and utilities for managing temporary workspaces, running shell commands, and controlling environment variables in automated tests.
Yes, with conditions. The package is stable and permissively licensed, with low install friction and no known vulnerabilities. However, maintenance is aging—the last release was 623 days ago—so adopt it only if you need its specific pytest fixtures for shell and environment testing and can accept slower response to future pytest or Python version changes.
Install
pytest-shutil on PyPI
pip
pip install pytest-shutiluv
uv add pytest-shutilpoetry
poetry add pytest-shutilInstalling pytest-shutil
Before you install
Low install friction with a pure-Python wheel distribution. Maintenance status is aging—last release was 623 days ago, though the repository remains active with recent commits and no archived status.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install pytest-shutil
# In conftest.py or test file:
pytest_plugins = ['pytest_shutil']
def test_example(workspace):
path = workspace.workspace
script = path / 'test.sh'
script.write_text('#!/bin/sh\necho hello')
workspace.run('test.sh')
Verify before relying
- Whether the workspace fixture's path object behavior remains stable after migration from path.py to pathlib in version 1.8.0
- Current compatibility with pytest versions beyond 4.0.0 and Python 3.13
Package facts
| License | MIT license (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — six, execnet, pytest, termcolor, importlib-metadata |
| Maintenance | aging — 623 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 220,856/month — #9,291 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_shutil-1.8.1-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pytest-fixture-configProvides configuration objects and decorators…
permissive · top 15,000 on PyPI
pytest-rabbitmqA pytest plugin that provides fixtures to start…
copyleft · top 15,000 on PyPI
pytest-redisA pytest plugin that provides fixtures for…
copyleft · top 15,000 on PyPI
pytest-postgresqlA pytest plugin that provides fixtures to…
copyleft · top 5,000 on PyPI
pytest-dockerpytest-docker provides pytest fixtures that…
permissive · top 5,000 on PyPI
pytest-unused-fixturesA pytest plugin that identifies and reports…
permissive · top 15,000 on PyPI
pytest-datadirA pytest plugin that provides fixtures for…
permissive · top 5,000 on PyPI
tempenvTemporarily override environment variables…
permissive · top 15,000 on PyPI
pytest-mock-resourcesProvides pytest fixtures that spin up real…
permissive · top 15,000 on PyPI
pytest-profilingPytest plugin that profiles test execution…
permissive · top 5,000 on PyPI