Skip to content

Commit 121de3e

Browse files
author
Sylvain MARIE
committed
Fixed TypeError: got an unexpected keyword argument 'indirect' with pytest 5+. Fixed #70
1 parent b541402 commit 121de3e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

pytest_cases/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ class _ParametrizationMark:
9191

9292
def __init__(self, mark):
9393
bound = get_parametrize_signature().bind(*mark.args, **mark.kwargs)
94+
remaining_kwargs = bound.arguments['kwargs']
95+
if len(remaining_kwargs) > 0:
96+
warn("parametrize kwargs not taken into account: %s. Please report it at"
97+
" https://github.com/smarie/python-pytest-cases/issues" % remaining_kwargs)
9498
self.param_names = get_param_argnames_as_list(bound.arguments['argnames'])
9599
self.param_values = bound.arguments['argvalues']
96100
try:
@@ -197,7 +201,7 @@ def get_pytest_parametrize_marks(f):
197201
return ()
198202

199203

200-
def _pytest_mark_parametrize(argnames, argvalues, ids=None):
204+
def _pytest_mark_parametrize(argnames, argvalues, ids=None, indirect=False, scope=None, **kwargs):
201205
""" Fake method to have a reference signature of pytest.mark.parametrize"""
202206
pass
203207

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
from pytest_cases import fixture_ref, pytest_parametrize_plus, pytest_fixture_plus
3+
4+
5+
@pytest_fixture_plus
6+
@pytest_parametrize_plus("variant", ['A', 'B'])
7+
def book1(variant):
8+
return variant
9+
10+
11+
@pytest.fixture
12+
def book2():
13+
return
14+
15+
16+
@pytest_parametrize_plus("name", [
17+
fixture_ref(book1),
18+
'hi',
19+
'ih',
20+
fixture_ref(book2),
21+
])
22+
def test_get_or_create_book(name):
23+
print(name)

0 commit comments

Comments
 (0)