testpath
Test utilities for code working with files and commands
What it is and what it does
Testpath is a small testing utility library that provides helpers for code that needs to verify filesystem state and mock system command execution. It offers functions like `assert_isfile()` to check file existence and a context manager to record and verify calls to external commands like `git`. The package has no runtime dependencies, making it lightweight to add to test suites.
It's designed for developers writing tests that interact with the filesystem or shell commands—situations where you want to verify that your code called the right external tools or created the expected files. The library sits in the Jupyter ecosystem and is used by projects that need reliable, simple assertions for file and command testing.
Use it for:
- Verify that your code creates or modifies expected files during testing without leaving test artifacts.
- Mock and record calls to system commands like git, ensuring your code invokes them with correct arguments.
- Assert filesystem state in unit tests—check that a file exists or is a directory.
- Test code that shells out to external tools by capturing and validating command invocations.
- Build test suites for file-processing utilities that need to verify output files and side effects.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Testpath provides utilities for testing code that interacts with files and system commands, including filesystem assertions and mocking of command-line calls.
Yes, if you're testing code that touches the filesystem or calls system commands. It's lightweight, permissively licensed, and has no dependencies. The aging maintenance status is a minor concern—the package is stable and unlikely to need frequent updates—but verify compatibility with your test framework before committing to it in a new project.
Install
testpath on PyPI
pip
pip install testpathuv
uv add testpathpoetry
poetry add testpathInstalling testpath
Before you install
Low install friction with no runtime dependencies. Maintenance is aging—last release was in 2022, though the repository remains active.
License in practice
Licensed under BSD (permissive), so you can use it freely in commercial and open-source projects without significant restrictions.
Quickstart
pip install testpath
import testpath
testpath.assert_isfile(path)
with testpath.assert_calls('git', ['add', path]):
function_under_test()
Verify before relying
- Whether the package is actively maintained or in maintenance-only mode given the gap between last release and current date.
- Compatibility with modern testing frameworks beyond the stated Python 3.5+ support.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>= 3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 1,633 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,766,957/month — #3,577 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: testpath-0.6.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
testfixturesTestfixtures provides helpers and mock objects…
permissive · top 5,000 on PyPI
pyfakefspyfakefs mocks the Python file system modules…
permissive · top 5,000 on PyPI
assertsProvides stand-alone assertion functions for…
unclear · top 15,000 on PyPI
mock-openProvides a drop-in replacement for…
permissive · top 15,000 on PyPI
poxPox provides utilities for filesystem…
permissive · top 5,000 on PyPI
mockmock provides a backport of Python's standard…
permissive · top 1,000 on PyPI
TestSlideTestSlide is a test framework for Python that…
permissive · top 15,000 on PyPI
mocksftpProvides an in-process SFTP server for testing…
permissive · top 15,000 on PyPI
flexmockflexmock creates mock, stub, spy, and fake…
permissive · top 15,000 on PyPI
calleeProvides argument matchers for unittest.mock…
permissive · top 15,000 on PyPI