I have long chain of fixtures with different scopes. I want cache it and redefine first fixtures of chain sometimes. Code below doesn't work cause b(session-scope fixture) depends on a(function scope). I know that I can copy b and c bodies to test_1.py
file and change scopes. But it's WET. Is there some way to do that? May be pytest plugins.
conftest.py:
import pytest
@pytest.fixture('session')
def a():
return 'a'
@pytest.fixture('session')
def b(a):
return a + 'b'
@pytest.fixture('module')
def c(b):
return b + ' c'
test_1.py:
import pytest
@fixture('function')
def a():
return 'a1'
def test_c(c):
assert c == 'a1 b c'
Aucun commentaire:
Enregistrer un commentaire