Skip to content

Commit eb1ce8d

Browse files
BCSS-20899: Align with playwright-python-blueprint (#101)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> A change to the reporting in the playwright-python-blueprint was in conflict with our conftest.py file, so this brings in that change and aligns us back to the blueprint. ## Context <!-- Why is this change required? What problem does it solve? --> This change amends the reporting so it includes the description of the test in the HTML, and ensures we don't fall behind the playwright-python-blueprint. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [ ] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
2 parents eeafd72 + 7a03be8 commit eb1ce8d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

conftest.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77
import pytest
88
import os
9+
import typing
910
from dotenv import load_dotenv
1011
from pathlib import Path
12+
from _pytest.python import Function
13+
from pytest_html.report_data import ReportData
1114
from utils.load_properties_file import PropertiesFile
1215

16+
# Environment Variable Handling
17+
1318
LOCAL_ENV_PATH = Path(os.getcwd()) / "local.env"
1419

1520

@@ -35,3 +40,27 @@ def smokescreen_properties() -> dict:
3540
@pytest.fixture
3641
def general_properties() -> dict:
3742
return PropertiesFile().get_general_properties()
43+
44+
45+
# HTML Report Customization
46+
47+
48+
def pytest_html_report_title(report: ReportData) -> None:
49+
report.title = "BCSS Test Automation Report"
50+
51+
52+
def pytest_html_results_table_header(cells: list) -> None:
53+
cells.insert(2, "<th>Description</th>")
54+
55+
56+
def pytest_html_results_table_row(report: object, cells: list) -> None:
57+
description = getattr(report, "description", "N/A")
58+
cells.insert(2, f"<td>{description}</td>")
59+
60+
61+
@pytest.hookimpl(hookwrapper=True)
62+
def pytest_runtest_makereport(item: Function) -> typing.Generator[None, None, None]:
63+
outcome = yield
64+
if outcome is not None:
65+
report = outcome.get_result()
66+
report.description = str(item.function.__doc__)

0 commit comments

Comments
 (0)