Skip to content

Commit efa8c40

Browse files
add documentation and sample for dom finalization hook
1 parent 1473ea8 commit efa8c40

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,27 @@ additional HTML and log output with a notice that the log is empty:
259259
del data[:]
260260
data.append(html.div('No log output captured.', class_='empty log'))
261261
262+
Modifying the whole test document
263+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
264+
265+
Finally, for major customizations, you may manipulate and update the resulting
266+
html document prior to finalization by hooking :code:`pytest_html_report_final_dom`.
267+
268+
.. code-block:: python
269+
270+
import pytest
271+
272+
def pytest_html_report_final_dom(document):
273+
from importlib.resources import read_text
274+
js = read_text(".", "fancy.js")
275+
for node in list(iter(document)):
276+
if isinstance(node, html.head):
277+
node.extend([html.script(raw(js), type="text/javascript")])
278+
279+
280+
281+
282+
262283
Display options
263284
---------------
264285

0 commit comments

Comments
 (0)