{"id":28027,"library":"parametrize-from-file","title":"parametrize-from-file","description":"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.","status":"active","version":"0.21.0","language":"python","source_language":"en","source_url":"https://github.com/todofixthis/parametrize-from-file","tags":["pytest","parametrize","testing","fixtures"],"install":[{"cmd":"pip install parametrize-from-file","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"The module exports a top-level function with the same name as the package.","wrong":"from parametrize_from_file import parametrize_from_file","symbol":"parametrize_from_file","correct":"import parametrize_from_file"},{"note":"add_source is a function, not a submodule.","wrong":"import parametrize_from_file.add_source","symbol":"parametrize_from_file.add_source","correct":"from parametrize_from_file import add_source"}],"quickstart":{"code":"import parametrize_from_file\n\n@parametrize_from_file\n@pytest.mark.parametrize(\"x, expected\", [\n    (1, 2),\n    (2, 4),\n])\ndef test_double(x, expected):\n    assert x * 2 == expected\n","lang":"python","description":"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."},"warnings":[{"fix":"Use @parametrize_from_file(format='yaml') or rename/convert files to JSON.","message":"In 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.","severity":"breaking","affected_versions":">=0.20.0"},{"fix":"Ensure @parametrize_from_file is the outermost decorator (i.e., directly above the test function, below any @pytest.mark.*).","message":"The decorator must be applied BEFORE @pytest.mark.parametrize. If applied after, parametrize_from_file will not be able to intercept the parametrization.","severity":"gotcha","affected_versions":"all"},{"fix":"Use @parametrize_from_file(source='...') instead.","message":"The 'parametrize_from_file.add_source' function was deprecated in v0.18.0 and will be removed in a future release.","severity":"deprecated","affected_versions":">=0.18.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Remove the --parametrize-from-file-format argument and specify format within the decorator: @parametrize_from_file(format='yaml').","cause":"Using the command-line option for an older version that was removed in v0.20.0.","error":"pytest: error: unrecognized arguments: --parametrize-from-file-format"},{"fix":"Use @parametrize_from_file() with parentheses, even if no arguments are passed.","cause":"Using the decorator without parentheses when no extra arguments are needed.","error":"TypeError: parametrize_from_file() missing 1 required positional argument: 'params'"},{"fix":"Specify the file explicitly: @parametrize_from_file(source='data.yaml').","cause":"The default file name does not match the test function name (e.g., test file is 'data.yaml' but expects 'test_my_func.yaml').","error":"pytest.fail.Exception: Could not find a test data file for test_my_func"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}