Parameterize unit tests with values from YAML, TOML, and NT files.
Project description
Parametrizing your tests—in other words, separating the test data from the test code—is frequently a good idea. It makes it easier to add new test cases, while also making it easier to read and understand the test code.
parametrize_from_file provides a convenient way to parametrize tests when using the popular pytest framework. The central idea is to keep the parameters in their own files, separate from the test code. This prevents long lists of parameters from dwarfing your test code, and often allows parameters to be specified more clearly and succinctly than would be possible in python. Below is the basic workflow that this package enables:
Write test cases in a JSON, YAML, TOML, or NestedText file:
# test_misc.yml test_addition: - a: 1 b: 2 c: 3
Decorate the corresponding test functions with parametrize_from_file:
# test_misc.py import parametrize_from_file @parametrize_from_file def test_addition(a, b, c): assert a + b == c
Run pytest as usual:
$ pytest
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 parametrize_from_file-0.1.0.tar.gz
.
File metadata
- Download URL: parametrize_from_file-0.1.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adf83a26bd52876889cf47db658edebcbb3b56b16cc1ddcbb5ddc6ab53a15502 |
|
MD5 | f5080b8834db9fb1b61f94930edab2be |
|
BLAKE2b-256 | a1c4d660db51c3c3c70771694cce91359955a24176516daf6259e402f642d731 |
File details
Details for the file parametrize_from_file-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: parametrize_from_file-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe059ae3e3f4ebbf912ec474047bfc82e88ffe4b66c82d1065507aad33feb435 |
|
MD5 | 71a2963837bbbeba801175aa8a8ac84c |
|
BLAKE2b-256 | 6c0d820fc2e5264b95d74d0fa036795823e46a5e511a758430d26e0e400c8a5f |