Skip to content

Allow changing the query parameters of the printed URI. #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 3 additions & 4 deletions src/pytest_html/basereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions src/pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down