Skip to content

Commit 710bbcb

Browse files
author
Sylvain MARIE
committed
Fixed issue when @parametrize_with_cases was used on a fixture in a conftest.py. Fixes #196
1 parent 937f7d0 commit 710bbcb

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

pytest_cases/plugin.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,12 +1408,14 @@ def pytest_addoption(parser):
14081408
PYTEST_CONFIG = None # type: _pytest.config.Config
14091409

14101410

1411-
# @hookspec(historic=True)
1412-
def pytest_configure(config):
1413-
# store the received config object for future use; see #165 & #166
1411+
def pytest_load_initial_conftests(early_config):
1412+
# store the received config object for future use; see #165 #166 #196
14141413
global PYTEST_CONFIG
1415-
PYTEST_CONFIG = config
1414+
PYTEST_CONFIG = early_config
1415+
14161416

1417+
# @hookspec(historic=True)
1418+
def pytest_configure(config):
14171419
# validate the config
14181420
allowed_values = ('normal', 'skip')
14191421
reordering_choice = config.getoption(_OPTION_NAME)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pytest_cases import fixture, parametrize_with_cases
2+
3+
4+
def case_a():
5+
return 1
6+
7+
8+
@fixture
9+
@parametrize_with_cases("a", cases=case_a)
10+
def dummy_fixture(a):
11+
return a + 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def test_foo(dummy_fixture):
2+
"""Before the fix this test would not even start because a conftest loading error was appearing"""
3+
assert dummy_fixture == 2

0 commit comments

Comments
 (0)