From ba035400b9d9dc281cccf12d2c28394fa68eeedf Mon Sep 17 00:00:00 2001 From: qdewaghe Date: Mon, 9 Jun 2025 23:44:10 +0200 Subject: [PATCH] Allow changing the query parameters of the printed URI. --- docs/user_guide.rst | 10 ++++++++++ src/pytest_html/basereport.py | 7 +++---- src/pytest_html/plugin.py | 6 ++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/user_guide.rst b/docs/user_guide.rst index 691c86f2..58a62555 100644 --- a/docs/user_guide.rst +++ b/docs/user_guide.rst @@ -296,6 +296,16 @@ The following values may be passed: * :code:`xpassed` * :code:`rerun` +Summary Report Line +~~~~~~~~~~~~~~~~~~~ + +It is possible to add query parameters to the printed URI in the terminal summary. + +.. code-block:: ini + + [pytest] + summary_query_parameters = ?sort=result&visible=failed,error + Results Table Sorting ~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/pytest_html/basereport.py b/src/pytest_html/basereport.py index cfcc74b2..909c76a5 100644 --- a/src/pytest_html/basereport.py +++ b/src/pytest_html/basereport.py @@ -193,10 +193,9 @@ def pytest_sessionfinish(self, session): @pytest.hookimpl(trylast=True) def pytest_terminal_summary(self, terminalreporter): - terminalreporter.write_sep( - "-", - f"Generated html report: {self._report_path.as_uri()}", - ) + uri = self._report_path.as_uri() + params = self._config.getini("summary_query_parameters") + terminalreporter.write_sep("-", f"Generated html report: {uri}{params}") @pytest.hookimpl(trylast=True) def pytest_collectreport(self, report): diff --git a/src/pytest_html/plugin.py b/src/pytest_html/plugin.py index 949a6ffa..a7692f3a 100644 --- a/src/pytest_html/plugin.py +++ b/src/pytest_html/plugin.py @@ -54,6 +54,12 @@ def pytest_addoption(parser): default="passed", help="row(s) to render collapsed on open.", ) + parser.addini( + "summary_query_parameters", + type="string", + default="", + help="query parameters to be printed in the terminal summary", + ) parser.addini( "max_asset_filename_length", default=255,