Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend to use the name argument in the pytest.fixture decorator #55

Merged
merged 5 commits into from
Apr 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,27 @@ keeping in mind the option of breaking up the test into multiple tests.
This structure makes it easy to understand what is required before test
execution, how the test works and what it checks for in the end.

# Test Fixture
jdkandersson marked this conversation as resolved.
Show resolved Hide resolved

When declaring fixture functions and requesting them in the same Python module,
jdkandersson marked this conversation as resolved.
Show resolved Hide resolved
it is recommended to add a "fixture" prefix or suffix to the fixture function
name and use the `name` argument in the `pytest.fixture` decorator to name the
fixture. This can help protect you from accidentally using the fixture function
instead of requesting the fixture in test case function parameters.

An example of using the `name` argument in the `pytest.fixture` decorator:

```python3
jdkandersson marked this conversation as resolved.
Show resolved Hide resolved
import pytest

@pytest.fixture(name="app")
def app_fixture():
return "app"

def test_my_fixture(app):
assert app == "app"
```

## Test Coverage

Unit tests check whether the intended functionality has been implemented. This
Expand Down