Skip to content

Commit

Permalink
feature: improve handling parameters in the pytest.mark.parametrize d…
Browse files Browse the repository at this point in the history
…ecorator.

If you specify the `ids` parameter, the reporter will use it as value of parameter in the test case.

```python
@pytest.mark.parametrize("enter", [enter_from_meta, enter_from_expedition, enter_from_news],
                         ids=["enter_from_meta", "enter_from_expedition", "enter_from_news"])
def test_enter(enter):
    enter()
```
  • Loading branch information
gibiw committed Sep 27, 2024
1 parent 0a82f12 commit 999e12c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions qase-pytest/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# qase-pytest 6.1.4b1

## What's new

Improve handling parameters in the `pytest.mark.parametrize` decorator.
If you specify the `ids` parameter, the reporter will use it as value of parameter in the test case.

```python
@pytest.mark.parametrize("enter", [enter_from_meta, enter_from_expedition, enter_from_news],
ids=["enter_from_meta", "enter_from_expedition", "enter_from_news"])
def test_enter(enter):
enter()
```

# qase-pytest 6.1.3

## 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.3"
version = "6.1.4b1"
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
6 changes: 5 additions & 1 deletion qase-pytest/src/qase/pytest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,14 @@ def _set_params(self, item) -> None:
for group in item._grouped_params:
self.runtime.result.add_param_groups(group)

ids = item.callspec.id.split("-")
i = 0
for key, val in item.callspec.params.items():
value = str(ids[i])
i += 1
if key.startswith("__pytest"):
continue
self.runtime.result.add_param(key, str(val))
self.runtime.result.add_param(key, value)

def _set_suite(self, item) -> None:
marker = item.get_closest_marker("qase_suite")
Expand Down

0 comments on commit 999e12c

Please sign in to comment.