pytest-datafiles
py.test plugin to create a 'tmp_path' containing predefined files/directories.
Decision gist · record as of 2026-08-14
Yes. This is a stable, low-friction plugin (pure Python, only pytest dependency) with active maintenance and no known vulnerabilities. It solves a common testing problem—data isolation—cleanly and has been proven in production since 2015. Install it if your tests work with files and you want to avoid fixture pollution or manual cleanup.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with only pytest as a runtime dependency.
- Actively maintained since 2015 with recent updates; the maintainer notes little activity because the plugin is stable and works as intended.
License · maintenance · safety
MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
last release 2026-01-04 (222 days) · last repo commit 2026-08-06 · 106 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 123,874 downloads/mo, #11,893 on PyPI
Alternatives
Verify before relying
pip install pytest-datafiles
import pytest
from pathlib import Path
@pytest.mark.datafiles('/path/to/file.txt')
def test_example(datafiles):
# datafiles is a pathlib.Path object pointing to the temp directory
assert (datafiles / 'file.txt').exists()- Whether the plugin works with pytest plugins that also manipulate tmp_path or fixture scoping
- Performance characteristics when copying very large file trees or many files per test
What it is and what it does
pytest-datafiles is a pytest plugin that automates the setup of test data by copying files and directories into a temporary directory before each test runs. You decorate a test function with @pytest.mark.datafiles() and list the files or directories you want copied, then receive a pathlib.Path object pointing to the temporary copy. This keeps your original test data untouched across test runs and ensures each test works on its own isolated copy.
The plugin is useful when tests need to read or modify files without side effects—common scenarios include testing on large media files, image processing, or any workflow where you want to verify file handling without corrupting your test fixtures. It supports both string paths and pathlib.Path objects, offers options to control directory nesting and duplicate file handling, and integrates seamlessly into pytest's fixture and marker system.
Use it for
- Testing video or image processing code on large files stored outside the test suite without modifying originals
- Running multiple tests on the same fixture files while ensuring each test gets an independent copy
- Verifying file I/O and modification logic in isolation, with automatic cleanup after each test
- Setting up complex directory structures for integration tests that need realistic file layouts
- Testing file-based tools or utilities where you need to confirm they don't corrupt the input data
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a stable, low-friction plugin (pure Python, only pytest dependency) with active maintenance and no known vulnerabilities. It solves a common testing problem—data isolation—cleanly and has been proven in production since 2015. Install it if your tests work with files and you want to avoid fixture pollution or manual cleanup.
Install
pytest-datafiles on PyPI
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained since 2015 with recent updates; the maintainer notes little activity because the plugin is stable and works as intended.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install pytest-datafiles
import pytest
from pathlib import Path
@pytest.mark.datafiles('/path/to/file.txt')
def test_example(datafiles):
# datafiles is a pathlib.Path object pointing to the temp directory
assert (datafiles / 'file.txt').exists()
Verify before relying
- Whether the plugin works with pytest plugins that also manipulate tmp_path or fixture scoping
- Performance characteristics when copying very large file trees or many files per test
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Actively maintained 222 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 123,874 / month, #11,893 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Testing |
Evidence: pytest_datafiles-3.0.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 fixture for test data files”
- pytest-datafilesA pytest plugin that copies specified files and directories into a…
- pytest-datadirA pytest plugin that provides fixtures for safely accessing test data…
- pytest-casespytest-cases lets you separate test case data from test code in…
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-helpers-namespace · pytest-regressions · pytest-datadir · pytest-xprocess · pytest-pythonpath · deadline-cloud-test-fixtures · pytest-cases · pytest-freezegun · pytest-logging