pytest-datadir
pytest plugin for test data directories and files
Decision gist · record as of 2026-08-14
Yes. This is a stable, well-maintained plugin (active since 2015, currently at version 1.8.0) with no security vulnerabilities, low install friction, and a clear, focused purpose. If your test suite uses file-based fixtures, it eliminates manual directory management and temporary file cleanup, making tests cleaner and safer. The permissive MIT license poses no restrictions.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later; test data directories must follow naming conventions (module-specific test_* folders or a global data folder).
- Low friction: pure Python wheel with only pytest as a runtime dependency.
- Actively maintained with a recent release (2025-07-30) and no known vulnerabilities.
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 2025-07-30 (380 days) · last repo commit 2026-07-13 · 275 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,767,458 downloads/mo, #3,576 on PyPI
Alternatives
Verify before relying
pip install pytest-datadir
# In test_hello.py with data/hello.txt and test_hello/spam.txt present:
from pathlib import Path
def test_read_global(shared_datadir):
contents = (shared_datadir / "hello.txt").read_text()
assert contents == "Hello World!\n"
def test_read_module(datadir):
contents = (datadir / "spam.txt").read_text()
assert contents == "eggs\n"What it is and what it does
pytest-datadir is a pytest plugin that simplifies working with test data by providing fixtures that automatically locate and manage test data files. It supports two organizational patterns: module-specific data directories (named to match your test module) and a shared global data folder. The plugin copies data to temporary locations during test execution, ensuring test isolation and preventing accidental modifications to original files.
The package offers three main fixtures: datadir for module-specific data, shared_datadir for global test data, and lazy variants (lazy_datadir and lazy_shared_datadir) that defer copying until files are actually accessed. All fixtures return pathlib.Path objects, making file operations straightforward. It requires Python 3.8 or later and integrates seamlessly into existing pytest workflows.
Use it for
- Load fixture files (JSON, CSV, XML) in unit tests without modifying originals or managing temporary cleanup.
- Share common test data across multiple test modules via a global data directory.
- Test file I/O operations safely by working with isolated copies that don't affect the source data.
- Reduce test setup boilerplate by automatically discovering and preparing test data based on directory naming conventions.
- Optimize test performance with lazy_datadir when only a subset of test data files are needed per test.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
This is a stable, well-maintained plugin (active since 2015, currently at version 1.8.0) with no security vulnerabilities, low install friction, and a clear, focused purpose. If your test suite uses file-based fixtures, it eliminates manual directory management and temporary file cleanup, making tests cleaner and safer. The permissive MIT license poses no restrictions.
Install
pytest-datadir on PyPI
Before you install
Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained with a recent release (2025-07-30) and no known vulnerabilities.
Requires Python 3.8 or later; test data directories must follow naming conventions (module-specific test_* folders or a global data folder).
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-datadir
# In test_hello.py with data/hello.txt and test_hello/spam.txt present:
from pathlib import Path
def test_read_global(shared_datadir):
contents = (shared_datadir / "hello.txt").read_text()
assert contents == "Hello World!\n"
def test_read_module(datadir):
contents = (datadir / "spam.txt").read_text()
assert contents == "eggs\n"
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 380 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,767,458 / month, #3,576 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/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: Testing |
Evidence: pytest_datadir-1.8.0-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 temporary data handling”
- pytest-datadirA pytest plugin that provides fixtures for safely accessing test data…
- pytest-datafilesA pytest plugin that copies specified files and directories into a…
- pytest-pgsqlA pytest plugin that provides fixtures for running tests against…
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-regressions · pytest-container · pytest-redis · pytest-datafiles · pytest-mypy-plugins · pytest-pgsql · pytest-unused-fixtures · pytest-mypy · pytest-describe · pytest-cookies