Skip to content

Commit cb09706

Browse files
authored
Fix: Handle legacy py html (#694)
1 parent 7ff7703 commit cb09706

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/pytest_html/basereport.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def pytest_sessionstart(self, session):
151151

152152
headers = self._report.data["resultsTableHeader"]
153153
session.config.hook.pytest_html_results_table_header(cells=headers)
154+
self._report.data["resultsTableHeader"] = _fix_py(headers)
154155

155156
self._report.set_data("runningState", "Started")
156157
self._generate_report()
@@ -216,6 +217,7 @@ def pytest_runtest_logreport(self, report):
216217
if not cells:
217218
return
218219

220+
cells = _fix_py(cells)
219221
data["resultsTableRow"] = cells
220222

221223
processed_logs = _process_logs(report)
@@ -279,3 +281,20 @@ def _process_outcome(report):
279281
def _process_links(links):
280282
a_tag = '<a target="_blank" href="{content}" class="col-links__extra {format_type}">{name}</a>'
281283
return "".join([a_tag.format_map(link) for link in links])
284+
285+
286+
def _fix_py(cells):
287+
# backwards-compat
288+
new_cells = []
289+
for html in cells:
290+
if not isinstance(html, str):
291+
if html.__module__.startswith("py."):
292+
warnings.warn(
293+
"The 'py' module is deprecated and support "
294+
"will be removed in a future release.",
295+
DeprecationWarning,
296+
)
297+
html = str(html)
298+
html = html.replace("col=", "data-column-type=")
299+
new_cells.append(html)
300+
return new_cells

0 commit comments

Comments
 (0)