Skip to content

Commit 91669e2

Browse files
author
Sylvain MARIE
committed
Minor @pytest_parametrize_plus improvement: if name is None, do not add is to kwargs nor change the function name
1 parent 8f21460 commit 91669e2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pytest_cases/main_fixtures.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,14 @@ def pytest_fixture_plus(scope="function",
459459
fixtures to create to represent parts of this fixture. See `unpack_fixture` for details.
460460
:param kwargs: other keyword arguments for `@pytest.fixture`
461461
"""
462-
# Compatibility for the 'name' argument
463-
if LooseVersion(pytest.__version__) >= LooseVersion('3.0.0'):
464-
# pytest version supports "name" keyword argument
465-
kwargs['name'] = name
466-
elif name is not None:
467-
# 'name' argument is not supported in this old version, use the __name__ trick.
468-
fixture_func.__name__ = name
462+
if name is not None:
463+
# Compatibility for the 'name' argument
464+
if LooseVersion(pytest.__version__) >= LooseVersion('3.0.0'):
465+
# pytest version supports "name" keyword argument
466+
kwargs['name'] = name
467+
elif name is not None:
468+
# 'name' argument is not supported in this old version, use the __name__ trick.
469+
fixture_func.__name__ = name
469470

470471
# (1) Collect all @pytest.mark.parametrize markers (including those created by usage of @cases_data)
471472
parametrizer_marks = get_pytest_parametrize_marks(fixture_func)

0 commit comments

Comments
 (0)