Registry / testing / parametrize-from-file

parametrize-from-file

JSON →
library0.21.0pypypi✓ verified 83d ago

A pytest plugin that allows parametrizing test functions with values read from external config files (JSON, TOML, YAML, INI, etc.). Version 0.21.0 supports Python ~=3.8. Releases are infrequent, typically a few times per year.

pip install parametrize-from-file
INSTALL
IMPORT
SIG · PARAMETRIZE-FROM-F
P
parametrize-from-file
testingpythonv0.21.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parametrize_from_file
import parametrize_from_file
from parametrize_from_file import parametrize_from_file
The module exports a top-level function with the same name as the package.
parametrize_from_file.add_source
from parametrize_from_file import add_source
import parametrize_from_file.add_source
add_source is a function, not a submodule.

The decorator loads parameters from a file named after the test module (e.g., test_*.yaml). The file is expected in the same directory as the test file.

import parametrize_from_file @parametrize_from_file @pytest.mark.parametrize("x, expected", [ (1, 2), (2, 4), ]) def test_double(x, expected): assert x * 2 == expected
Debug
Known issues
breakingIn v0.20.0, the default config format changed from YAML to JSON. Existing YAML test data files will not be found unless you specify the format explicitly.
fix
Use @parametrize_from_file(format='yaml') or rename/convert files to JSON.
affects: >=0.20.0
gotchaThe decorator must be applied BEFORE @pytest.mark.parametrize. If applied after, parametrize_from_file will not be able to intercept the parametrization.
fix
Ensure @parametrize_from_file is the outermost decorator (i.e., directly above the test function, below any @pytest.mark.*).
affects: all
deprecatedThe 'parametrize_from_file.add_source' function was deprecated in v0.18.0 and will be removed in a future release.
fix
Use @parametrize_from_file(source='...') instead.
affects: >=0.18.0
Errors
Common errors & fixes
pytest: error: unrecognized arguments: --parametrize-from-file-format
Using the command-line option for an older version that was removed in v0.20.0.
fix
Remove the --parametrize-from-file-format argument and specify format within the decorator: @parametrize_from_file(format='yaml').
TypeError: parametrize_from_file() missing 1 required positional argument: 'params'
Using the decorator without parentheses when no extra arguments are needed.
fix
Use @parametrize_from_file() with parentheses, even if no arguments are passed.
pytest.fail.Exception: Could not find a test data file for test_my_func
The default file name does not match the test function name (e.g., test file is 'data.yaml' but expects 'test_my_func.yaml').
fix
Specify the file explicitly: @parametrize_from_file(source='data.yaml').
Upgrade
Version history
0.21.0latest on PyPI · released May 1, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
parametrize-from-file — pip install parametrize-from-file · libregistry