pytest plugin for test data directories and files
Project description
pytest-datadir
pytest plugin for manipulating test data directories and files.
Usage
pytest-datadir will look up for a directory with the name of your module or the global 'data' folder. Let's say you have a structure like this:
.
├── data/
│ └── hello.txt
├── test_hello/
│ └── spam.txt
└── test_hello.py
You can access the contents of these files using injected variables datadir
(for test_ folder) or shared_datadir
(for data folder):
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'
pytest-datadir will copy the original file to a temporary folder, so changing the file contents won't change the original data file.
Both datadir
and shared_datadir
fixtures are pathlib.Path
objects.
Releases
Follow these steps to make a new release:
- Create a new branch
release-X.Y.Z
frommaster
. - Update
CHANGELOG.rst
. - Open a PR.
- After it is green and approved, push a new tag in the format
X.Y.Z
.
Travis will deploy to PyPI automatically.
Afterwards, update the recipe in conda-forge/pytest-datadir-feedstock.
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_datadir-1.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dafc8deaabcd8bd1daa7f850c8e53ed16edbfac28770f5844f774ea357d562bf |
|
MD5 | 7d6e3d65497bc1115fb6173ca77a6164 |
|
BLAKE2b-256 | 86c6f04b2f15597327ca07170e67a054f8c55df1737e0730f7432b8f5e6a49bf |