| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: pytest-datadir |
| 3 |
Version: 1.4.1 |
| 4 |
Summary: pytest plugin for test data directories and files |
| 5 |
Home-page: http://github.com/gabrielcnr/pytest-datadir |
| 6 |
Author: Gabriel Reis |
| 7 |
Author-email: [email protected] |
| 8 |
License: MIT |
| 9 |
Keywords: pytest test unittest directory file |
| 10 |
Classifier: Development Status :: 5 - Production/Stable |
| 11 |
Classifier: Intended Audience :: Developers |
| 12 |
Classifier: License :: OSI Approved :: MIT License |
| 13 |
Classifier: Operating System :: OS Independent |
| 14 |
Classifier: Programming Language :: Python :: 3.6 |
| 15 |
Classifier: Programming Language :: Python :: 3.7 |
| 16 |
Classifier: Programming Language :: Python :: 3.8 |
| 17 |
Classifier: Programming Language :: Python :: 3.9 |
| 18 |
Classifier: Programming Language :: Python :: 3.10 |
| 19 |
Classifier: Topic :: Software Development :: Quality Assurance |
| 20 |
Classifier: Topic :: Software Development :: Testing |
| 21 |
Requires-Python: >=3.6 |
| 22 |
Description-Content-Type: text/markdown |
| 23 |
License-File: LICENSE |
| 24 |
License-File: AUTHORS |
| 25 |
|
| 26 |
# pytest-datadir |
| 27 |
|
| 28 |
pytest plugin for manipulating test data directories and files. |
| 29 |
|
| 30 |
[](https://github.com/gabrielcnr/pytest-datadir/workflows/build/badge.svg?branch=master) |
| 31 |
[](https://pypi.python.org/pypi/pytest-datadir) |
| 32 |
[](https://anaconda.org/conda-forge/pytest-datadir) |
| 33 |
 |
| 34 |
[](https://github.com/psf/black) |
| 35 |
|
| 36 |
|
| 37 |
# Usage |
| 38 |
pytest-datadir will look up for a directory with the name of your module or the global 'data' folder. |
| 39 |
Let's say you have a structure like this: |
| 40 |
|
| 41 |
``` |
| 42 |
. |
| 43 |
├── data/ |
| 44 |
│ └── hello.txt |
| 45 |
├── test_hello/ |
| 46 |
│ └── spam.txt |
| 47 |
└── test_hello.py |
| 48 |
``` |
| 49 |
You can access the contents of these files using injected variables `datadir` (for *test_* folder) or `shared_datadir` |
| 50 |
(for *data* folder): |
| 51 |
|
| 52 |
```python |
| 53 |
def test_read_global(shared_datadir): |
| 54 |
contents = (shared_datadir / "hello.txt").read_text() |
| 55 |
assert contents == "Hello World!\n" |
| 56 |
|
| 57 |
|
| 58 |
def test_read_module(datadir): |
| 59 |
contents = (datadir / "spam.txt").read_text() |
| 60 |
assert contents == "eggs\n" |
| 61 |
``` |
| 62 |
|
| 63 |
pytest-datadir will copy the original file to a temporary folder, so changing the file contents won't change the original data file. |
| 64 |
|
| 65 |
Both `datadir` and `shared_datadir` fixtures are `pathlib.Path` objects. |
| 66 |
|
| 67 |
# Releases |
| 68 |
|
| 69 |
Follow these steps to make a new release: |
| 70 |
|
| 71 |
1. Create a new branch `release-X.Y.Z` from `master`. |
| 72 |
2. Update `CHANGELOG.rst`. |
| 73 |
3. Open a PR. |
| 74 |
4. After it is **green** and **approved**, push a new tag in the format `X.Y.Z`. |
| 75 |
|
| 76 |
Travis will deploy to PyPI automatically. |
| 77 |
|
| 78 |
Afterwards, update the recipe in [conda-forge/pytest-datadir-feedstock](https://github.com/conda-forge/pytest-datadir-feedstock). |
| 79 |
|
| 80 |
# License |
| 81 |
|
| 82 |
MIT. |