Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions qase-pytest/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# qase-pytest 8.3.0

## What's new

- Exposed `QasePytestPlugin.get_qase_ids(item)` as a public static method
so third-party pytest plugins can read the Qase IDs associated with a
pytest item without parsing the `qase_id` marker themselves.

# qase-pytest 8.2.0

## 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 = "8.2.0"
version = "8.3.0"
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: 3 additions & 3 deletions qase-pytest/src/qase/pytest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def pytest_collection_modifyitems(self, session, config, items):
new_items = []
for item in items:
if item.get_closest_marker('qase_id'):
ids = QasePytestPlugin._get_qase_ids(item)
ids = QasePytestPlugin.get_qase_ids(item)
if any(id in self.execution_plan for id in ids):
new_items.append(item)

Expand Down Expand Up @@ -430,7 +430,7 @@ def _set_testops_ids(self, item) -> None:
self.runtime.result.set_testops_project_mapping(project_code, testops_ids)
else:
# Single project mode: use old testops_ids
self.runtime.result.testops_ids = QasePytestPlugin._get_qase_ids(item)
self.runtime.result.testops_ids = QasePytestPlugin.get_qase_ids(item)
except (AttributeError, TypeError, ValueError):
pass

Expand Down Expand Up @@ -542,7 +542,7 @@ def __is_xfail_mark(report):
return hasattr(report, 'wasxfail')

@staticmethod
def _get_qase_ids(item) -> Union[None, List[int]]:
def get_qase_ids(item) -> Union[None, List[int]]:
marker = item.get_closest_marker("qase_id")
if marker is None:
return None
Expand Down
14 changes: 7 additions & 7 deletions qase-pytest/tests/tests_qase_pytest/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,37 @@ def make_plugin():


class TestGetQaseIds:
"""Test _get_qase_ids static method edge cases."""
"""Test get_qase_ids static method edge cases."""

def test_returns_none_when_no_marker(self):
item = make_mock_item()
assert QasePytestPlugin._get_qase_ids(item) is None
assert QasePytestPlugin.get_qase_ids(item) is None

def test_returns_list_with_integer_id(self):
marker = make_marker(id=42)
item = make_mock_item(markers={"qase_id": marker})
assert QasePytestPlugin._get_qase_ids(item) == [42]
assert QasePytestPlugin.get_qase_ids(item) == [42]

def test_returns_list_from_comma_separated_string(self):
marker = make_marker(id="1,2,3")
item = make_mock_item(markers={"qase_id": marker})
assert QasePytestPlugin._get_qase_ids(item) == [1, 2, 3]
assert QasePytestPlugin.get_qase_ids(item) == [1, 2, 3]

def test_returns_none_when_id_kwarg_is_none(self):
marker = make_marker(id=None)
item = make_mock_item(markers={"qase_id": marker})
assert QasePytestPlugin._get_qase_ids(item) is None
assert QasePytestPlugin.get_qase_ids(item) is None

def test_handles_string_with_spaces(self):
marker = make_marker(id="10, 20, 30")
item = make_mock_item(markers={"qase_id": marker})
assert QasePytestPlugin._get_qase_ids(item) == [10, 20, 30]
assert QasePytestPlugin.get_qase_ids(item) == [10, 20, 30]

def test_raises_on_non_numeric_string(self):
marker = make_marker(id="abc")
item = make_mock_item(markers={"qase_id": marker})
with pytest.raises(ValueError):
QasePytestPlugin._get_qase_ids(item)
QasePytestPlugin.get_qase_ids(item)


class TestGetTitle:
Expand Down
Loading