pytest-dev / pytest-dev/pytest
Enable fixture dynamic scoping during test run
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
pytest version 5.2.2
Tried to use dynamic scopes for fixtures. However, the scope definition is executed only once - during the fixture definition.
We would like to have option to control fixture scope during test run.
This will allow code re-use in tests which need the code in different scope.
For example: set up a docker - one test needs it in function level and a separate test needs it in module level.
@pytest.fixture()
def some_fixture():
pass
# test_method.py
@pytest.mark.scope('some_fixture', 'module')
def test_method(some_fixture):
pass
# test_function.py
@pytest.mark.scope('some_fixture', 'function')
def test_method(some_fixture):
pass
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
Start by reproducing the dynamic-scope example on pytest 5.2.2 and trace where fixture scope is evaluated; the issue names no files or tests. Done means fixture scope can be selected per test run as shown, while preserving the existing fixture behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100