Skip to content

Commit 8c97045

Browse files
hook point for inspecting/modifying dom output prior to finalization
1 parent e8bd795 commit 8c97045

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pytest_html/hooks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
from py.xml import html
6+
57

68
def pytest_html_report_title(report):
79
""" Called before adding the title to the report """
@@ -21,3 +23,7 @@ def pytest_html_results_table_row(report, cells):
2123

2224
def pytest_html_results_table_html(report, data):
2325
""" Called after building results table additional HTML. """
26+
27+
28+
def pytest_html_report_final_dom(document: html.html):
29+
""" Called after the entire document has been created. """

pytest_html/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ def generate_summary_item(self):
558558

559559
doc = html.html(head, body)
560560

561+
session.config.hook.pytest_html_report_final_dom(document=doc)
562+
561563
unicode_doc = "<!DOCTYPE html>\n{}".format(doc.unicode(indent=2))
562564

563565
# Fix encoding issues, e.g. with surrogates

0 commit comments

Comments
 (0)