pytest-param-files
A small package to generate parametrized pytests from external files.
Simply create a text file with the following (dot) format:
[name1] description
.
input content
.
expected output content
,
[name2] description
.
input content
.
expected output content
,
Then, use the param_file pytest marker to create a parametrized test:
from pathlib import Path
import pytest
import my_function
PATH = Path(__file__).parent.joinpath("test_file.txt")
@pytest.mark.param_file(PATH, fmt="dot")
def test_function(file_params):
assert my_function(file_params.content) == file_params.expected
and the output will be:
$ pytest -v test_file.py
...
test_file.py::test_function[1-name1] PASSED
test_file.py::test_function[8-name2] FAILED
Alternatively use the assert_expected method, which will can handle more rich assertion features:
@pytest.mark.param_file(PATH, fmt="dot")
def test_function(file_params):
actual = my_function(file_params.content)
assert file_params.assert_expected(actual, rstrip=True)
$ pytest -v test_file.py
...
test_file.py::test_function[1-name1] PASSED
test_file.py::test_function[8-name2] FAILED
...
E AssertionError: Actual does not match expected
E --- /path/to/test_file.txt:8
E +++ (actual)
E @@ -1 +1 @@
E -content
E +other
Installation
Install from PyPI:
$ pip install pytest-param-files
or install locally (for development):
$ pip install -e .
Regenerating expected output on failures
EXPERIMENTAL
Running pytest with the --regen-file-failure option will regenerate the parameter file with actual output, if any test fails.
Other formats
TODO ...
Metadata
Release files for pytest_param_files 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_param_files-0.3.1.tar.gz | 7.2 kB | Without provenance | Details for pytest_param_files-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_param_files-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_param_files-0.3.1-py3-none-any.whl |
Total release size: 13.2 kB
Release files / pytest_param_files-0.3.1.tar.gz
| Download URL | pytest_param_files-0.3.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f44db0cd7fea59785d3a80f3dc449874f70bcd9cd1a9ff627cb37f732f0e83a
|
|
BLAKE2b-256 checksum How to use checksums |
4b8ed70e8dbaa02680e6a193b80cf059b63ab1384e61a9520e7549eabd458f04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.26.0
|
Release files / pytest_param_files-0.3.1-py3-none-any.whl
| Download URL | pytest_param_files-0.3.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11e20bfd382341502a5b1334095a00445411f371a29769cb5fd8a97b58d4054a
|
|
BLAKE2b-256 checksum How to use checksums |
b622e972dc4eedc61fe7b69f1e0b31edf67fb0e41091f4b456bd30132b279ae8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.26.0
|
Security for pytest_param_files 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.