Name | pytest-fixtures-fixtures JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | Handy fixtues to access your fixtures from your _pytest_ tests. |
upload_time | 2025-09-09 07:33:50 |
maintainer | Antonio Feregrino |
docs_url | None |
author | Antonio Feregrino |
requires_python | >=3.10 |
license | MIT |
keywords |
testing
pytest
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pytest fixtures fixtures
Fixtures, for fixtures. Handy fixtures to access your test fixtures from your _pytest_ tests.
## Installation
```bash
pip install pytest-fixtures-fixtures
```
## Fixture Usage Guide
This plugin provides several fixtures to help you read and interact with test fixture files in your pytest tests.
Everything starts whith where you define your fixtures, by default, this plugin expects your fixtures to live in a folder named `tests/fixtures` from the root of your project. For example:
```text
src
├── script.py
tests/
├── fixtures/
│ ├── users_data.txt
│ ├── app_config.json
│ └── error_logs.jsonl
└── test_script.py
```
If you wanted to read the `users_data.txt` file, you would use the `read_fixture` fixture:
```python
def test_users_data(read_fixture):
data = read_fixture("users_data.txt")
assert "Alice" in data
```
If you wanted to read the `app_config.json` file, you would use the `read_json_fixture` fixture:
```python
def test_app_config(read_json_fixture):
config = read_json_fixture("app_config.json")
assert config["database"]["host"] == "localhost"
assert config["debug"] is True
```
There are more fixtures available to read different types of fixture files, including providing your own deserialization function. You can read the [Fixtures Usage](docs/fixtures-usage.md) docs for more information.
## Configure default fixtures directory
You can configure the default fixtures directory in several ways, the most common one is by redefining the `fixtures_path` fixture in your tests:
```python
@pytest.fixture
def fixtures_path(tmp_path):
"""Use a temporary directory for fixtures."""
path = tmp_path / "my_fixtures"
path.mkdir()
return path
```
You can read more about how to configure the default fixtures directory using configuration files or CLI in the [Configuration](docs/configuration.md) docs.
## Use fixtures to parametrize your tests
This plugin also provides a decorator to parametrize your tests using fixture files, for example:
```csv
id,a,b,c
add_positive,1,2,3
add_negative,1,-1,0
add_zero,5,0,5
```
```python
@parametrize_from_fixture("data.csv")
def test_addition(a, b, c):
assert int(a) + int(b) == int(c)
```
Will be expanded into three tests, each with different values for `a`, `b`, and `c` based on the data in the fixture file.
You can read more about how to use the `parametrize_from_fixture` decorator in the [Parametrize](docs/parametrize.md) docs.
## A good example
`pytest-fixtures-fixtures` is tested using itself, you can see the tests in the [tests](tests) directory.
## Documentation
- **[Fixtures Usage](docs/fixtures-usage.md)** - Complete guide to all available fixtures
- **[Test Parametrization](docs/parametrize.md)** - Data-driven testing with external files
- **[Configuration](docs/configuration.md)** - Customize fixtures directory and behavior
## Why Use This Plugin?
- **Clean separation** of test data and test logic
- **Multiple formats** supported with consistent API
- **Automatic validation** and clear error messages
- **Flexible configuration** for different environments
- **Parametrization support** with custom test IDs
## Contributing
We welcome contributions! Please see our contributing guidelines and feel free to submit issues or pull requests.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-fixtures-fixtures",
"maintainer": "Antonio Feregrino",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Antonio Feregrino <antonio.feregrino@gmail.com>",
"keywords": "testing, pytest",
"author": "Antonio Feregrino",
"author_email": "Antonio Feregrino <antonio.feregrino@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a5/41/f302e48aee36c0956c090e322f529e77508351980d045b35ee671a26a69c/pytest_fixtures_fixtures-0.3.0.tar.gz",
"platform": null,
"description": "# pytest fixtures fixtures\n\nFixtures, for fixtures. Handy fixtures to access your test fixtures from your _pytest_ tests.\n\n## Installation\n\n```bash\npip install pytest-fixtures-fixtures\n```\n\n## Fixture Usage Guide\n\nThis plugin provides several fixtures to help you read and interact with test fixture files in your pytest tests.\n\nEverything starts whith where you define your fixtures, by default, this plugin expects your fixtures to live in a folder named `tests/fixtures` from the root of your project. For example:\n\n```text\nsrc\n\u251c\u2500\u2500 script.py\ntests/\n\u251c\u2500\u2500 fixtures/\n\u2502 \u251c\u2500\u2500 users_data.txt\n\u2502 \u251c\u2500\u2500 app_config.json\n\u2502 \u2514\u2500\u2500 error_logs.jsonl\n\u2514\u2500\u2500 test_script.py\n```\n\nIf you wanted to read the `users_data.txt` file, you would use the `read_fixture` fixture:\n\n```python\ndef test_users_data(read_fixture):\n data = read_fixture(\"users_data.txt\")\n assert \"Alice\" in data\n```\n\nIf you wanted to read the `app_config.json` file, you would use the `read_json_fixture` fixture:\n\n```python\ndef test_app_config(read_json_fixture):\n config = read_json_fixture(\"app_config.json\")\n assert config[\"database\"][\"host\"] == \"localhost\"\n assert config[\"debug\"] is True\n```\n\nThere are more fixtures available to read different types of fixture files, including providing your own deserialization function. You can read the [Fixtures Usage](docs/fixtures-usage.md) docs for more information.\n\n## Configure default fixtures directory\n\nYou can configure the default fixtures directory in several ways, the most common one is by redefining the `fixtures_path` fixture in your tests:\n\n```python\n@pytest.fixture\ndef fixtures_path(tmp_path):\n \"\"\"Use a temporary directory for fixtures.\"\"\"\n path = tmp_path / \"my_fixtures\"\n path.mkdir()\n return path\n```\n\nYou can read more about how to configure the default fixtures directory using configuration files or CLI in the [Configuration](docs/configuration.md) docs.\n\n## Use fixtures to parametrize your tests\n\nThis plugin also provides a decorator to parametrize your tests using fixture files, for example:\n\n```csv\nid,a,b,c\nadd_positive,1,2,3\nadd_negative,1,-1,0\nadd_zero,5,0,5\n```\n\n```python\n@parametrize_from_fixture(\"data.csv\")\ndef test_addition(a, b, c):\n assert int(a) + int(b) == int(c)\n```\n\nWill be expanded into three tests, each with different values for `a`, `b`, and `c` based on the data in the fixture file.\n\nYou can read more about how to use the `parametrize_from_fixture` decorator in the [Parametrize](docs/parametrize.md) docs.\n\n## A good example\n\n`pytest-fixtures-fixtures` is tested using itself, you can see the tests in the [tests](tests) directory.\n\n## Documentation\n\n- **[Fixtures Usage](docs/fixtures-usage.md)** - Complete guide to all available fixtures\n- **[Test Parametrization](docs/parametrize.md)** - Data-driven testing with external files\n- **[Configuration](docs/configuration.md)** - Customize fixtures directory and behavior\n\n## Why Use This Plugin?\n\n - **Clean separation** of test data and test logic \n - **Multiple formats** supported with consistent API \n - **Automatic validation** and clear error messages \n - **Flexible configuration** for different environments \n - **Parametrization support** with custom test IDs \n\n## Contributing\n\nWe welcome contributions! Please see our contributing guidelines and feel free to submit issues or pull requests.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Handy fixtues to access your fixtures from your _pytest_ tests.",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/fferegrino/pytest-fixtures-fixtures",
"Issues": "https://github.com/fferegrino/pytest-fixtures-fixtures/issues",
"Repository": "https://github.com/fferegrino/pytest-fixtures-fixtures.git"
},
"split_keywords": [
"testing",
" pytest"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7e6b0d9b745a51d913f7f31493b8ccb35c53f5b93419d7c441b934a89f04106a",
"md5": "bdfa5607dc98bc02783e1e180eb68ff5",
"sha256": "5ffc06ac6d9fd11906c91366d9c9998007434fcba60f39f5c1c68ff3da1fd266"
},
"downloads": -1,
"filename": "pytest_fixtures_fixtures-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bdfa5607dc98bc02783e1e180eb68ff5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 10005,
"upload_time": "2025-09-09T07:33:48",
"upload_time_iso_8601": "2025-09-09T07:33:48.966988Z",
"url": "https://files.pythonhosted.org/packages/7e/6b/0d9b745a51d913f7f31493b8ccb35c53f5b93419d7c441b934a89f04106a/pytest_fixtures_fixtures-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a541f302e48aee36c0956c090e322f529e77508351980d045b35ee671a26a69c",
"md5": "a1bc7dc1dd9bb7833d1753b24df2fe17",
"sha256": "6ad1d7ee66e07a400dc251c2fa9981b142f77dac53dfefa867c4e1da253b5a96"
},
"downloads": -1,
"filename": "pytest_fixtures_fixtures-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "a1bc7dc1dd9bb7833d1753b24df2fe17",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 8825,
"upload_time": "2025-09-09T07:33:50",
"upload_time_iso_8601": "2025-09-09T07:33:50.047637Z",
"url": "https://files.pythonhosted.org/packages/a5/41/f302e48aee36c0956c090e322f529e77508351980d045b35ee671a26a69c/pytest_fixtures_fixtures-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-09 07:33:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fferegrino",
"github_project": "pytest-fixtures-fixtures",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytest-fixtures-fixtures"
}