Skip to content

Commit

Permalink
Fixed issue when @parametrize_with_cases was used on a fixture in a…
Browse files Browse the repository at this point in the history
… `conftest.py`. Fixes #196
  • Loading branch information
Sylvain MARIE committed Apr 7, 2021
1 parent 937f7d0 commit 710bbcb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pytest_cases/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,12 +1408,14 @@ def pytest_addoption(parser):
PYTEST_CONFIG = None # type: _pytest.config.Config


# @hookspec(historic=True)
def pytest_configure(config):
# store the received config object for future use; see #165 & #166
def pytest_load_initial_conftests(early_config):
# store the received config object for future use; see #165 #166 #196
global PYTEST_CONFIG
PYTEST_CONFIG = config
PYTEST_CONFIG = early_config


# @hookspec(historic=True)
def pytest_configure(config):
# validate the config
allowed_values = ('normal', 'skip')
reordering_choice = config.getoption(_OPTION_NAME)
Expand Down
11 changes: 11 additions & 0 deletions pytest_cases/tests/cases/issues/issue_196/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from pytest_cases import fixture, parametrize_with_cases


def case_a():
return 1


@fixture
@parametrize_with_cases("a", cases=case_a)
def dummy_fixture(a):
return a + 1
3 changes: 3 additions & 0 deletions pytest_cases/tests/cases/issues/issue_196/test_issue_196.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_foo(dummy_fixture):
"""Before the fix this test would not even start because a conftest loading error was appearing"""
assert dummy_fixture == 2

0 comments on commit 710bbcb

Please sign in to comment.