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.
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.5.0.tar.gz
.
File metadata
- Download URL: pytest-datadir-1.5.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1617ed92f9afda0c877e4eac91904b5f779d24ba8f5e438752e3ae39d8d2ee3f |
|
MD5 | 8a5b6b1caa3c7414f76b21715f3bdd99 |
|
BLAKE2b-256 | aa97a93900d82635aa3f419c3cd2059b4de7d7fe44e415eaf00c298854582dcc |
File details
Details for the file pytest_datadir-1.5.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_datadir-1.5.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34adf361bcc7b37961bbc1dfa8d25a4829e778bab461703c38a5c50ca9c36dc8 |
|
MD5 | dfe8a44043d2d044d2f0dec7a0ee8125 |
|
BLAKE2b-256 | 7c9096b9474cddda5ef9e10e6f1871c0fadfa153b605e0e749ba30437bfb62a0 |