Skip to content

Commit

Permalink
Fixed an issue where using keyword argnames in `@pytest.mark.parame…
Browse files Browse the repository at this point in the history
…trize` would cause `IndexError: tuple index out of range` in the tests collection phase. Fixed #234 (#236)

Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
  • Loading branch information
smarie and Sylvain MARIE authored Nov 8, 2021
1 parent d67e5bb commit bc9ca05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

### 3.6.5 - Bugfix

- 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).

### 3.6.4 - Bugfix

- 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)
- 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)

### 3.6.3 - Bugfix

Expand Down
3 changes: 2 additions & 1 deletion pytest_cases/common_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ def get_param_names(fnode):
p_markers = get_parametrization_markers(fnode)
param_names = []
for paramz_mark in p_markers:
param_names += get_param_argnames_as_list(paramz_mark.args[0])
argnames = paramz_mark.args[0] if len(paramz_mark.args) > 0 else paramz_mark.kwargs['argnames']
param_names += get_param_argnames_as_list(argnames)
return param_names


Expand Down
9 changes: 9 additions & 0 deletions pytest_cases/tests/pytest_extension/issues/test_issue_234.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest


@pytest.mark.parametrize(
argnames="test_arg",
argvalues=[1, 2, 3]
)
def test_keyword_paramz(test_arg):
assert True

0 comments on commit bc9ca05

Please sign in to comment.