pytest
pytest copied to clipboard
Header loading text order
I'm trying to customize the test header:
$ pytest
=================================================================== test session starts ===================================================================
platform linux -- Python 3.10.13, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/ubuntu/pymapdl
configfile: pyproject.toml
testpaths: tests
plugins: cov-4.1.0, anyio-4.3.0, sphinx-0.6.0, pytest_pyvista-0.1.9, rerunfailures-14.0, memprof-0.2.0
by modifying this function:
@pytest.hookimpl(trylast=True)
def pytest_report_header(config, start_path, startdir):
return "Useful reports"
However the platform linux ...
get always first, which is annoying, and, in my humble opinion, it is a bug.
$ pytest
=================================================================== test session starts ===================================================================
platform linux -- Python 3.10.13, pytest-8.1.1, pluggy-1.4.0
Useful reports
rootdir: /home/ubuntu/pymapdl
configfile: pyproject.toml
testpaths: tests
plugins: cov-4.1.0, anyio-4.3.0, sphinx-0.6.0, pytest_pyvista-0.1.9, rerunfailures-14.0, memprof-0.2.0
I'm happy to do a PR on this if this issue feedback is positive.
Presumably, it is this function which it should be changed:
https://github.com/pytest-dev/pytest/blob/470edc5884faf7ae9e5297f233a4909d4579fbdb/src/_pytest/terminal.py#L760
Hi germa89,
I looked into this issue, and you are correct you need to change pytest_sessionstart
Placing the code there manages to place "Useful Reports" ahead of
platform linux ...
I'm slightly confused at what you intend to achieve so can you provide more details about this issue?