Skip to content

Commit

Permalink
fix: issue with parameters
Browse files Browse the repository at this point in the history
If we use parameters like this `pytest.mark.parametrize(argnames="foo", argvalues=["bar","baz"])`, then get an error:

```log
INTERNALERROR> File "/usr/local/lib/python3.12/site-packages/qase/pytest/plugin.py", line 79, in pytest_collection_modifyitems
INTERNALERROR> param_name, values = mark.args
INTERNALERROR> ^^^^^^^^^^^^^^^^^^
INTERNALERROR> ValueError: not enough values to unpack (expected 2, got 0)
```
  • Loading branch information
gibiw committed Sep 6, 2024
1 parent 481558d commit 526d9ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
15 changes: 14 additions & 1 deletion qase-pytest/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# qase-pytest 6.1.1b2
# qase-pytest 6.1.1b4

## What's new

Fix an issue with parameters like this `pytest.mark.parametrize(argnames="foo", argvalues=["bar","baz"])`:

```log
INTERNALERROR> File "/usr/local/lib/python3.12/site-packages/qase/pytest/plugin.py", line 79, in pytest_collection_modifyitems
INTERNALERROR> param_name, values = mark.args
INTERNALERROR> ^^^^^^^^^^^^^^^^^^
INTERNALERROR> ValueError: not enough values to unpack (expected 2, got 0)
```

# qase-pytest 6.1.1b3

## What's new

Expand Down
12 changes: 8 additions & 4 deletions qase-pytest/src/qase/pytest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@ def pytest_collection_modifyitems(self, session, config, items):
# Extract single and grouped params from the item's markers
for mark in item.iter_markers():
if mark.name == 'parametrize':
param_name, values = mark.args
if ',' in param_name:
grouped_params.append(param_name.split(','))

if len(mark.args) != 0:
param_name, values = mark.args
if ',' in param_name:
grouped_params.append(param_name.split(','))
else:
param_name = mark.kwargs.get('argnames')
if ',' in param_name:
grouped_params.append(param_name.split(','))
# Attach the captured params to the test item
item._grouped_params = grouped_params

Expand Down

0 comments on commit 526d9ea

Please sign in to comment.