Skip to content

Commit ad48104

Browse files
author
Sylvain MARIE
committed
Fixed minor bug with parametrized @pytest_fixture_plus: spaces are now correctly removed when multiple parameter names are provided in the same parametrize call. Fixes #27
1 parent f0b273e commit ad48104

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pytest_cases/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,15 @@ def pytest_fixture_plus(scope="function",
308308
"name in a @pytest.mark.parametrize mark")
309309

310310
else:
311+
paramnames = [name.strip() for name in m.param_names]
312+
311313
# create a fixture function for this parameter
312314
def _param_fixture(request):
313315
"""a dummy fixture that simply returns the parameter"""
314316
return request.param
315317

316318
# generate a fixture name (find an available name if already used)
317-
gen_name = fixture_func.__name__ + "__" + 'X'.join(m.param_names) # + "__gen"
319+
gen_name = fixture_func.__name__ + "__" + 'X'.join(paramnames) # + "__gen"
318320
i = 0
319321
_param_fixture.__name__ = gen_name
320322
while _param_fixture.__name__ in dir(module):
@@ -334,7 +336,7 @@ def _param_fixture(request):
334336
"".format(_param_fixture.__name__, module))
335337

336338
# remember
337-
params_map[_param_fixture.__name__] = m.param_names
339+
params_map[_param_fixture.__name__] = paramnames
338340

339341
# wrap the fixture function so that each of its parameter becomes the associated fixture name
340342
new_parameter_names = tuple(params_map.keys())

pytest_cases/tests/simple/test_fixtures_params.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ def myfix(arg1, arg2):
1616
def test_one(myfix):
1717
print(myfix)
1818

19+
20+
@pytest_fixture_plus
21+
@pytest.mark.parametrize("arg1, arg2", [
22+
(1, 2),
23+
(3, 4),
24+
])
25+
def myfix2(arg1, arg2):
26+
return arg1, arg2
27+
28+
def test_two(myfix2):
29+
print(myfix)

0 commit comments

Comments
 (0)