pytest plugin to provide data from files loaded automatically
Project description
Overview
A pytest plugin to provide fixtures to load test data from files automatically.
Usage
Fixtures
This plugin provides following fixtures for each test modules.
test_data_info
test_data_info provides a namedtuple object, data_from_files.ModuleInfo, has the following values for each test modules.
root: test root dir, <package_dir>/tests/ by default and is configurable with –test-root (test_root) option.
datadir: test data dir using the fixture will be searched under <root>/<test_data_dirname>/, where test_data_dirname is configurable with –test-data-dirname option.
if the test code using the fixture is tests/test_foo.py, then datadir becomes tests/data/foo/
if the test code using the fixture is tests/foo/bar/test_baz.py, then datadir becomes tests/data/foo/bar/baz
subdirs: names of sub dirs relative to datadir if such dirs exist.
test_data
test_data provides a list of or a list of lists of namedtuple objects, data_from_files.DataInfo, has the following values.
data: data loaded from a file <path> under <datadir>
path: a file path contains the data
datadir: dir contains the test data file
Options
–test-root: test root dir where test data are seached [<package_dir>/tests]
–test-data-dirname: test data dir name [data]
–test-data-pattern: test data file path pattern relative to datadir [**/*.*]
Examples
tests/test_plugin.py and test data under tests/data/plugin/
tests/test_plugin_no_data.py and test data under tests/data/plugin_no_data
tests/foo/test_bar.py and test data under tests/data/foo/bar
Installation
Requirements
How to install
PyPI:
pip install pytest_data_from_files
From git repo:
pip install git+https://github.com/ssato/pytest-data-from-files
Build wheel and install it:
tox -e dists && pip install dist/pytest_data_from_files-*.whl
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-data-from-files-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0efa8648914c415ce094c12418767a0e080712647c535bbdda63dcd6935f872 |
|
MD5 | fda1efbeecf46733733caf00e80c46a8 |
|
BLAKE2b-256 | e1426597d0f3abadf2e936c24723150868990af71bbff792a2f0a5897285cc7d |
Hashes for pytest_data_from_files-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3115600e2f81619b8b7619b8ef9a0a17e83a5afb3f5a6fef8d8f9b41d01b4ce4 |
|
MD5 | 02a9ba15ef59aa6e7101981d3fed0d33 |
|
BLAKE2b-256 | 90cf87655dc68fdbe0dc996f2075e012b9a2b68e3f4a85ecbcf636da4e5c53ae |