Handy fixtues to access your fixtures from your _pytest_ tests.
Project description
pytest fixtures fixtures
Fixtures, for fixtures. Handy fixtures to access your test fixtures from your pytest tests.
Installation
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:
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:
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:
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 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:
@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.
Use fixtures to parametrize your tests
This plugin also provides a decorator to parametrize your tests using fixture files, for example:
id,a,b,c
add_positive,1,2,3
add_negative,1,-1,0
add_zero,5,0,5
@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.
A good example
pytest-fixtures-fixtures is tested using itself, you can see the tests in the tests directory.
Documentation
- Fixtures Usage - Complete guide to all available fixtures
- Test Parametrization - Data-driven testing with external files
- Configuration - 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_fixtures_fixtures-0.3.1.tar.gz.
File metadata
- Download URL: pytest_fixtures_fixtures-0.3.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40b065b3ab990739efa71055ce321fd830bc90a50dd33f64f3286b014a1406a7
|
|
| MD5 |
30d2ab1e1c990a7c569869246df7f14e
|
|
| BLAKE2b-256 |
3c6a3cdef445f4a96f2dd38424ced69fbe830c4b9b3a9eb51da867788c2aa8f4
|
Provenance
The following attestation bundles were made for pytest_fixtures_fixtures-0.3.1.tar.gz:
Publisher:
release.yml on fferegrino/pytest-fixtures-fixtures
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_fixtures_fixtures-0.3.1.tar.gz -
Subject digest:
40b065b3ab990739efa71055ce321fd830bc90a50dd33f64f3286b014a1406a7 - Sigstore transparency entry: 487362027
- Sigstore integration time:
-
Permalink:
fferegrino/pytest-fixtures-fixtures@106eb6ef57360c625ed89392f17db0828dd636ee -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fferegrino
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@106eb6ef57360c625ed89392f17db0828dd636ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_fixtures_fixtures-0.3.1-py3-none-any.whl.
File metadata
- Download URL: pytest_fixtures_fixtures-0.3.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1c3e3cf38066a9fc3398df2f5252f99b79322219e7fff6217e5b09cb25ff563
|
|
| MD5 |
8b70fa82f12144940bffd189e89104bc
|
|
| BLAKE2b-256 |
cb4d07c1fe17496e3b9dd71aac280a390fe7351403531add3b0b4024d2076ea9
|
Provenance
The following attestation bundles were made for pytest_fixtures_fixtures-0.3.1-py3-none-any.whl:
Publisher:
release.yml on fferegrino/pytest-fixtures-fixtures
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_fixtures_fixtures-0.3.1-py3-none-any.whl -
Subject digest:
b1c3e3cf38066a9fc3398df2f5252f99b79322219e7fff6217e5b09cb25ff563 - Sigstore transparency entry: 487362053
- Sigstore integration time:
-
Permalink:
fferegrino/pytest-fixtures-fixtures@106eb6ef57360c625ed89392f17db0828dd636ee -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fferegrino
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@106eb6ef57360c625ed89392f17db0828dd636ee -
Trigger Event:
push
-
Statement type: