skillfed

pytest-shutil

A goodie-bag of unix shell and environment tools for py.test

pytest-shutil v1.8.1 220.9K downloads/30d#9,291 on PyPI598
Permissive license MIT license AGING released

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-shutil

uv

uv add pytest-shutil

poetry

poetry add pytest-shutil

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: POSIXProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Topic :: Software Development :: LibrariesTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest fixtures for testingshell command execution in teststemporary workspace managementenvironment variable controlsubprocess testing utilitiesunix shell test helperspytest test environment setup
pytest-pluginshell-testingsubprocess-management

More Libraries packages