Skip to content

Commit bc9ca05

Browse files
smarieSylvain MARIE
andauthored
Fixed an issue where using keyword argnames in @pytest.mark.parametrize would cause IndexError: tuple index out of range in the tests collection phase. Fixed #234 (#236)
Co-authored-by: Sylvain MARIE <[email protected]>
1 parent d67e5bb commit bc9ca05

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

docs/changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3+
### 3.6.5 - Bugfix
4+
5+
- Fixed an issue where using keyword `argnames` in `@pytest.mark.parametrize` would cause `IndexError: tuple index out of range` in the tests collection phase. Fixed [#234](https://github.com/smarie/python-pytest-cases/issues/234).
6+
37
### 3.6.4 - Bugfix
48

5-
- A case id can now be a reserved keyword without triggering any `SyntaxError`, even if the case is transformed into a fixture. Fixes [#230](https://github.com/smarie/python-pytest-cases/issues/230)
9+
- A case id can now be a reserved keyword without triggering any `SyntaxError`, even if the case is transformed into a fixture. Fixes [#230](https://github.com/smarie/python-pytest-cases/issues/230)
610

711
### 3.6.3 - Bugfix
812

pytest_cases/common_pytest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ def get_param_names(fnode):
241241
p_markers = get_parametrization_markers(fnode)
242242
param_names = []
243243
for paramz_mark in p_markers:
244-
param_names += get_param_argnames_as_list(paramz_mark.args[0])
244+
argnames = paramz_mark.args[0] if len(paramz_mark.args) > 0 else paramz_mark.kwargs['argnames']
245+
param_names += get_param_argnames_as_list(argnames)
245246
return param_names
246247

247248

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import pytest
2+
3+
4+
@pytest.mark.parametrize(
5+
argnames="test_arg",
6+
argvalues=[1, 2, 3]
7+
)
8+
def test_keyword_paramz(test_arg):
9+
assert True

0 commit comments

Comments
 (0)