Skip to content

Commit 33acc2e

Browse files
committed
feat(pytest-bdd): implement titlePath
1 parent 1955a12 commit 33acc2e

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

allure-pytest-bdd/src/pytest_bdd_listener.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .utils import get_allure_links
2424
from .utils import convert_params
2525
from .utils import get_full_name
26+
from .utils import get_title_path
2627
from .utils import get_outline_params
2728
from .utils import get_pytest_params
2829
from .utils import get_pytest_report_status
@@ -59,6 +60,7 @@ def pytest_bdd_before_scenario(self, request, feature, scenario):
5960
full_name = get_full_name(feature, scenario)
6061
with self.lifecycle.schedule_test_case(uuid=uuid) as test_result:
6162
test_result.fullName = full_name
63+
test_result.titlePath = get_title_path(request, feature)
6264
test_result.name = get_test_name(item, scenario, params)
6365
test_result.description = get_allure_description(item, feature, scenario)
6466
test_result.descriptionHtml = get_allure_description_html(item)

allure-pytest-bdd/src/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from urllib.parse import urlparse
55
from uuid import UUID
6+
from pathlib import Path
67

78
import pytest
89

@@ -171,6 +172,16 @@ def get_full_name(feature, scenario):
171172
return f"{feature_path}:{scenario.name}"
172173

173174

175+
def get_rootdir(request):
176+
config = request.config
177+
return getattr(config, "rootpath", None) or Path(config.rootdir)
178+
179+
180+
def get_title_path(request, feature):
181+
parts = Path(feature.filename).relative_to(get_rootdir(request)).parts
182+
return [*parts[:-1], feature.name or parts[-1]]
183+
184+
174185
def get_uuid(*args):
175186
return str(UUID(md5(*args)))
176187

0 commit comments

Comments
 (0)