Coverage for pytest_beehave/html_steps_plugin.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2026-04-21 04:49 +0000

1"""HTML Acceptance Criteria column plugin for pytest-beehave.""" 

2 

3from __future__ import annotations 

4 

5import pytest 

6 

7 

8class HtmlStepsPlugin: 

9 """Adds an Acceptance Criteria column to pytest-html reports.""" 

10 

11 def pytest_html_results_table_header(self, cells: list[object]) -> None: 

12 """Insert the Acceptance Criteria column header. 

13 

14 Args: 

15 cells: The list of header cells to modify. 

16 """ 

17 cells.insert(2, "<th>Acceptance Criteria</th>") 

18 

19 def pytest_html_results_table_row( 

20 self, report: pytest.TestReport, cells: list[object] 

21 ) -> None: 

22 """Insert the Acceptance Criteria column value for each row. 

23 

24 Args: 

25 report: The test report for this row. 

26 cells: The list of row cells to modify. 

27 """ 

28 nodeid = report.nodeid 

29 if "tests/features/" in nodeid: 

30 docstring = getattr(report, "_beehave_docstring", "") or "" 

31 else: 

32 docstring = "" 

33 cells.insert(2, f"<td style='white-space: pre-wrap;'>{docstring}</td>")