-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Labels
Description
I have a simple test with parametrize and fixture:
@pytest.mark.repeat(3)
@pytest.parametrize("case", ["a","b","c"])
def test_1(case, my_fixture):
print("test_1 case: {}".format(case))
@pytest.fixture(scope="?")
def my_fixture():
yield # Executed at the end of the test
print("my_fixture")
Which pytest-repeat
scope and pytest
scope should I use if I want the following output?
test_1 case: a
test_1 case: b
test_1 case: c
my_fixture
test_1 case: a
test_1 case: b
test_1 case: c
my_fixture
test_1 case: a
test_1 case: b
test_1 case: c
my_fixture
So far I managed to have the following:
1- With pytest-repeat
's scope="session"
and pytest
's scope="session"
test_1 case: a
test_1 case: b
test_1 case: c
test_1 case: a
test_1 case: b
test_1 case: c
test_1 case: a
test_1 case: b
test_1 case: c
my_fixture
2- With pytest-repeat
's scope="session"
and pytest
's scope="function"
test_1 case: a
my_fixture
test_1 case: b
my_fixture
test_1 case: c
my_fixture
test_1 case: a
my_fixture
test_1 case: b
my_fixture
test_1 case: c
my_fixture
test_1 case: a
my_fixture
test_1 case: b
my_fixture
test_1 case: c
my_fixture
Thanks for your help.