pytest-dev / pytest-dev/pytest

Header loading text order

Open
#12,143 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: reporting type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the pytest_report_header hook shown in the issue and the session-header output produced by the sample pytest invocation. Reproduce the ordering with a hook returning “Useful reports,” then inspect the header-generation path to determine how the platform line is positioned. Done means the custom header appears in the requested order and the existing header output remains covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.