Skip to content

Commit b71bbf9

Browse files
hook point for inspecting/modifying dom output prior to finalization
1 parent 6553da9 commit b71bbf9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pytest_html/hooks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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
56

67
def pytest_html_report_title(report):
78
""" Called before adding the title to the report """
@@ -21,3 +22,6 @@ def pytest_html_results_table_row(report, cells):
2122

2223
def pytest_html_results_table_html(report, data):
2324
""" Called after building results table additional HTML. """
25+
26+
def pytest_html_report_final_dom(document : html.html):
27+
""" Called after the entire document has been created. Allows inspection and modification of DOM. """

pytest_html/plugin.py

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

555555
doc = html.html(head, body)
556556

557+
session.config.hook.pytest_html_report_complete(document=doc)
558+
557559
unicode_doc = "<!DOCTYPE html>\n{}".format(doc.unicode(indent=2))
558560

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

0 commit comments

Comments
 (0)