wemake-services / wemake-services/wemake-python-styleguide
Make sure we treat tests differently
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 430
- Avg merge
- 5h 14m
- Merged PRs (30d)
- 34
Description
When using pytest fixtures, you are supposed to just declare them as input arguments, and they will be automagically loaded. For example:
import pytest
from myapp import meaning_of_life
@pytest.fixture
def foo():
return 42
def test_meaning_of_life(foo):
meaning = meaning_of_life()
assert meaning == foo
This will violate rule 442, which is not desired in this case.
One could argue that fixtures should live on a different file than tests, but you run on the same issue if you have fixtures dependent on other fixtures:
import pytest
@pytest.fixture
def foo():
return 42
@pytest.fixture
def bar(foo):
return foo + 1
I think we need to make this feature "pytest aware", or just document that it there is conflict with it and might need to be disabled.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names rule 442 but no source file or test path. Start by locating rule 442's implementation and existing tests, then reproduce the two pytest fixture examples. Done requires an agreed behavior for fixture arguments, either pytest-aware handling or explicit documentation of the conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100