{"id":17654376,"url":"https://github.com/chrisjsewell/pytest-param-files","last_synced_at":"2025-10-10T08:10:20.877Z","repository":{"id":79564007,"uuid":"445985686","full_name":"chrisjsewell/pytest-param-files","owner":"chrisjsewell","description":"parametrize pytests via external files, with automatic regeneration","archived":false,"fork":false,"pushed_at":"2023-07-29T14:02:53.000Z","size":38,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-23T22:57:47.215Z","etag":null,"topics":["pytest","snapshot","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisjsewell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-09T03:41:40.000Z","updated_at":"2024-12-30T22:26:37.000Z","dependencies_parsed_at":"2025-03-10T22:32:36.730Z","dependency_job_id":"405c6048-36a4-4460-b93a-b9b6bda6347e","html_url":"https://github.com/chrisjsewell/pytest-param-files","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/chrisjsewell/pytest-param-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisjsewell%2Fpytest-param-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisjsewell%2Fpytest-param-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisjsewell%2Fpytest-param-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisjsewell%2Fpytest-param-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisjsewell","download_url":"https://codeload.github.com/chrisjsewell/pytest-param-files/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisjsewell%2Fpytest-param-files/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003292,"owners_count":26083555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytest","snapshot","yaml"],"created_at":"2024-10-23T12:14:01.552Z","updated_at":"2025-10-10T08:10:20.860Z","avatar_url":"https://github.com/chrisjsewell.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytest-param-files\n\n[![PyPI][pypi-badge]][pypi-link]\n\nA [pytest](https://docs.pytest.org) plugin to generate parametrized tests from external files,\nwith (optional) automated regeneration of expected output on failures.\n\nSimply create a text file with an available format:\n\n`yaml` format:\n```yaml\nname1:\n  description: optional description\n  input: |-\n    input content\n  expected: |-\n    expected output content\nname2:\n  description: optional description\n  input: |-\n    input content\n  expected: |-\n    expected output content\n```\n\n`dot` format (default):\n```\n[name1] optional description\n.\ninput content\n.\nexpected output content\n.\n\n[name2] optional description\n.\ninput content\n.\nexpected output content\n.\n```\n\nThen, use the `param_file` pytest marker to create a parametrized test:\n\n```python\nfrom pathlib import Path\nimport pytest\n\nimport my_function\n\nPATH = Path(__file__).parent.joinpath(\"test_file.txt\")\n\n@pytest.mark.param_file(PATH, fmt=\"dot\")\ndef test_function(file_params):\n    assert my_function(file_params.content) == file_params.expected\n```\n\nand the output will be:\n\n```console\n$ pytest -v test_file.py\n...\ntest_file.py::test_function[1-name1] PASSED\ntest_file.py::test_function[8-name2] FAILED\n```\n\nAlternatively use the `assert_expected` method, which will can handle more rich assertion features:\n\n```python\n@pytest.mark.param_file(PATH, fmt=\"dot\")\ndef test_function(file_params):\n    actual = my_function(file_params.content)\n    assert file_params.assert_expected(actual, rstrip=True)\n```\n\n```console\n$ pytest -v test_file.py\n...\ntest_file.py::test_function[1-name1] PASSED\ntest_file.py::test_function[8-name2] FAILED\n...\nE       AssertionError: Actual does not match expected\nE       --- /path/to/test_file.txt:8\nE       +++ (actual)\nE       @@ -1 +1 @@\nE       -content\nE       +other\n```\n\n## Installation\n\nInstall from [PyPI][pypi-link]:\n\n```console\n$ pip install pytest-param-files\n```\n\nor install locally (for development):\n\n```console\n$ pip install -e .\n```\n\n## Regenerating expected output on failures\n\nRunning pytest with the `--regen-file-failure` option will regenerate the parameter file with actual outputs of `assert_expected`, if any test fails.\n\n[pypi-badge]: https://img.shields.io/pypi/v/pytest_param_files.svg\n[pypi-link]: https://pypi.org/project/pytest_param_files\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisjsewell%2Fpytest-param-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisjsewell%2Fpytest-param-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisjsewell%2Fpytest-param-files/lists"}