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 382c09f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
21 changes: 20 additions & 1 deletion qase-pytest/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# qase-pytest 6.1.1b2
# qase-pytest 6.1.1b4

## What's new

Fixed an issue with parameters like this:

```python
@pytest.mark.parametrize(argnames="foo", argvalues=["bar","baz"])
```

The error was:

```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
2 changes: 1 addition & 1 deletion qase-pytest/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qase-pytest"
version = "6.1.1b3"
version = "6.1.1b4"
description = "Qase Pytest Plugin for Qase TestOps and Qase Report"
readme = "README.md"
keywords = ["qase", "pytest", "plugin", "testops", "report", "qase reporting", "test observability"]
Expand Down
11 changes: 8 additions & 3 deletions qase-pytest/src/qase/pytest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +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 382c09f

Please sign in to comment.