Skip to content

Commit 4a5c618

Browse files
author
Sylvain MARIE
committed
Fixed PluginValidationError when pytest_fixture_plus or pytest_parametrize_plus were used in a conftest.py file. Fixes #71
1 parent 0bf7768 commit 4a5c618

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pytest_cases/main_fixtures.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ def foo_fixture(request):
426426
return pytest_fixture_plus(**kwargs)(parametrized_f)
427427

428428

429+
# Fix for https://github.com/smarie/python-pytest-cases/issues/71
430+
# In order for pytest to allow users to import this symbol in conftest.py
431+
# they should be declared as optional plugin hooks.
432+
# A workaround otherwise would be to remove the 'pytest_' name prefix
433+
# See https://github.com/pytest-dev/pytest/issues/6475
434+
@pytest.hookimpl(optionalhook=True)
429435
@function_decorator
430436
def pytest_fixture_plus(scope="function",
431437
autouse=False,
@@ -975,6 +981,12 @@ def __init__(self, fixture):
975981
self.fixture = fixture
976982

977983

984+
# Fix for https://github.com/smarie/python-pytest-cases/issues/71
985+
# In order for pytest to allow users to import this symbol in conftest.py
986+
# they should be declared as optional plugin hooks.
987+
# A workaround otherwise would be to remove the 'pytest_' name prefix
988+
# See https://github.com/pytest-dev/pytest/issues/6475
989+
@pytest.hookimpl(optionalhook=True)
978990
def pytest_parametrize_plus(argnames, argvalues, indirect=False, ids=None, scope=None, **kwargs):
979991
"""
980992
Equivalent to `@pytest.mark.parametrize` but also supports the fact that in argvalues one can include references to

0 commit comments

Comments
 (0)