doc: document inversed lines with terminal report hooks (#7016)

It was surprising that `tryfirst=True` would not result in lines being
added to the beginning with `pytest_report_header`.
This is due to lines being reversed, and therefore the same applies to
`pytest_report_collectionfinish`.
This commit is contained in:
Daniel Hahler 2020-04-07 08:08:28 +02:00 committed by GitHub
parent bf3e64d473
commit 1fd14685c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -561,6 +561,7 @@ that result but it's probably better to avoid it.
For more information, consult the
:ref:`pluggy documentation about hookwrappers <pluggy:hookwrappers>`.
.. _plugin-hookorder:
Hook function ordering / call example
-------------------------------------

View File

@ -528,6 +528,13 @@ def pytest_report_header(config, startdir):
:param _pytest.config.Config config: pytest config object
:param startdir: py.path object with the starting dir
.. note::
Lines returned by a plugin are displayed before those of plugins which
ran before it.
If you want to have your line(s) displayed first, use
:ref:`trylast=True <plugin-hookorder>`.
.. note::
This function should be implemented only in plugins or ``conftest.py``
@ -542,11 +549,18 @@ def pytest_report_collectionfinish(config, startdir, items):
return a string or list of strings to be displayed after collection has finished successfully.
This strings will be displayed after the standard "collected X items" message.
These strings will be displayed after the standard "collected X items" message.
:param _pytest.config.Config config: pytest config object
:param startdir: py.path object with the starting dir
:param items: list of pytest items that are going to be executed; this list should not be modified.
.. note::
Lines returned by a plugin are displayed before those of plugins which
ran before it.
If you want to have your line(s) displayed first, use
:ref:`trylast=True <plugin-hookorder>`.
"""