Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
pytest plugin for manipulating test data directories and files
| Date | Stars |
|---|---|
| 2026-07-24 | 275 |
| 2026-07-25 | 275 |
| 2026-07-28 | 275 |
| 2026-07-30 | 275 |
| 2026-08-06 | 275 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# pytest-datadir
pytest plugin for manipulating test data directories and files.
[](https://github.com/gabrielcnr/pytest-datadir/workflows/build/badge.svg?branch=master)
[](https://pypi.python.org/pypi/pytest-datadir)
[](https://anaconda.org/conda-forge/pytest-datadir)

[](https://github.com/psf/black)
# Usage
`pytest-datadir` automatically looks for a directory matching your module's name or a global `data` folder.
Consider the following directory structure:
```
.
├── data/
│ └── hello.txt
├── test_hello/
│ └── spam.txt
└── test_hello.py
```
You can access file contents using the injected fixtures:
- `datadir` (for module-specific `test_*` folders)
- `shared_datadir` (for the global `data` folder)
```python
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"
```
The contents of the data directory are copied to a temporary folder, ensuring safe file modifications without affecting other tests or original files.
Both `datadir` and `shared_datadir` fixtures return `pathlib.Path` objects.
## lazy_datadir
Version 1.7.0 introduced the `lazy_datadir` fixture, which only copies files and directories when accessed via the `joinpath` method or the `/` operator.
```python
def test_read_module(lazy_datadir):
contents = (lazy_datadir / "spam.txt").read_text()
assert contents == "eggs\n"
```
Unlike `datadir`, `lazy_datadir` is an object that only implements `joinpath` and `/` operations. While not fully backward-compatible with `datadir`, most tests can switch to `lazy_datadir` without modifications.
### lazy_shared_datadir
`lazy_shared_datadir` is similar to `lazy_datadir`, but applied to the shared data directory `shared_datadir`.
That is, instead of copying all files in `shared_datadir`, files are only copied as necessary when accessed via `joinpath` or the `/` operator.
This allows for a shared data directory to be pulled from lazily in the same manner as `lazy_datadir`.
```python
def test_read_global(lazy_shared_datadir):
contents = (lazy_shared_datadir / "hello.txt").read_text()
assert contents == "Hello World!\n"
```
# License
MIT.
Excerpt of 2,685 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:0e6771c78fcd6273, topic:testing