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
File details
Details for the file pytest-datadir-1.4.1.tar.gz
.
File metadata
- Download URL: pytest-datadir-1.4.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f7a3c4def6ac4cac3cc8181139ab53bd2667231052bd40cb07081748d4420f0 |
|
MD5 | d5043376db09d710e24a71b96026d728 |
|
BLAKE2b-256 | ae98640d2c1d309506df53a4a6ef9dc8e80a0a3ff78b21cd42aca1ad2a6e3ea0 |
Provenance
File details
Details for the file pytest_datadir-1.4.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_datadir-1.4.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 095f441782b1b907587eca7227fdbae94be43f1c96b4b2cbcc6801a4645be1af |
|
MD5 | 73f4639639c9723b8bebf5f5696a5211 |
|
BLAKE2b-256 | 460f063f1d9754258254a61d20926ef1a7635f72a42604b12c036e0fc77aa1be |