Skip to content

Add option to split report #177

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

Closed
wants to merge 8 commits into from
Closed
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
39 changes: 39 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,45 @@ additional HTML and log output with a notice that the log is empty:
del data[:]
data.append(html.div('No log output captured.', class_='empty log'))

Grouping test results
~~~~~~~~~~~~~~~~~~~~~

By default, the generated report will be a flat array containing the results of all the defined
tests. It is possible to group these results by defining some keys. It also allows defining a group
hierarchy of undefined depth.

Group keys are defined in the :code:`pytest_runtest_makereport` hook. The following example defines
2 keys `key1` and `key2` whose value will be the `argx` and `argy` values passed to the test.

.. code-block:: python

import pytest
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.key1 = item.funcargs["argx"]
report.key2 = item.funcargs["argy"]

Then to generate a grouped report, you can use the `--group-by` option:

.. code-block:: bash

$ pytest --html=report.html --group-by key1 --group-by key2

Keys will be considered in the order the are given on the command line. The previous example will
generate the following hierarchy:

.. code-block::

key1 = "Value 1"
|-- key2 = "Value 1.1"
|-- key2 = "Value 1.2"
key1 = "Value 2"
|-- key2 = "Value 2.1"
|-- key2 = "Value 2.2"


Display options
---------------

Expand Down
Loading