Skip to content
Snippets Groups Projects
Commit 5615a529 authored by Florian Bruhin's avatar Florian Bruhin
Browse files

Improve rendering of cell tags

parent 11f99f26
Branches
No related tags found
No related merge requests found
Pipeline #359734 failed
......@@ -63,6 +63,7 @@ class VeiledResultPlugin:
self.exitstatus: pytest.ExitCode | None = None
def _record_cell_tags(self, report: pytest.TestReport) -> None:
"""Collect recorded cell tags from a teardown report."""
path, _lineno, _domaininfo = report.location
props = dict(report.user_properties)
......@@ -79,10 +80,13 @@ class VeiledResultPlugin:
def _exercise_name(self, path: str) -> str:
name = pathlib.PurePath(path).stem.removeprefix("test_").replace("_", " ")
cell_tags = self.cell_tags.get(path)
if cell_tags:
name += f" ({', '.join(cell_tags)})"
return name
cell_tags = {tag.replace("-", " ") for tag in self.cell_tags.get(path, [])}
cell_tags.discard(name)
if not cell_tags:
return name
return f"{name} ({', '.join(sorted(cell_tags))})"
def pytest_sessionfinish(self, exitstatus: pytest.ExitCode) -> None:
self.exitstatus = exitstatus
......
......@@ -226,10 +226,11 @@ class TestVeiledResultPlugin:
assert vrp.result() == expected_result
@pytest.mark.parametrize(
"tag, tag_str",
"tag, tag_suffix",
[
("single-tag", "single-tag"),
(["multi-tag-1", "multi-tag-2"], "multi-tag-1, multi-tag-2"),
("single-tag", " (single tag)"),
(["multi-tag-1", "multi-tag-2"], " (multi tag 1, multi tag 2)"),
("cell-tag-property", ""),
],
)
def test_cell_tag_property(
......@@ -237,7 +238,7 @@ class TestVeiledResultPlugin:
pytester: pytest.Pytester,
vrp: run_tests.VeiledResultPlugin,
tag: str | list[str],
tag_str: str,
tag_suffix: str,
) -> None:
pytester.makepyfile(
f"""
......@@ -257,8 +258,8 @@ class TestVeiledResultPlugin:
assert res.ret == pytest.ExitCode.OK
res.assert_outcomes(passed=1)
title = f"cell tag property ({tag_str})"
assert vrp.result()["tests"].keys() == {title}
title = f"cell tag property{tag_suffix}"
assert set(vrp.result()["tests"].keys()) == {title}
def test_cell_tag_property_invalid_type(
self, pytester: pytest.Pytester, vrp: run_tests.VeiledResultPlugin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment