Open
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