Pytest: Introduce new option to skip header and summary

Created on 16 Jan 2020  路  10Comments  路  Source: pytest-dev/pytest

6454 reminds me that sometimes we want to skip header and summary entirely from the output (posting examples online for example). Currently the only way to skip headers is to use -q, but this is a global option which affects many other parts (like diff and progress reporting).

How about a --lean-terminal or something which only skips both header and summary?

reporting proposal

Most helpful comment

That's correct, I'm a -.5 on this change because I find the header very useful in bug reports and don't think omitting it is very helpful.

I also have a general preference for less config options, because the more we add the harder it becomes to learn pytest or to write exhaustive self-tests and reliable plugins.

All 10 comments

A more concrete example:

位 python -m pytest src -ra
======================== test session starts ========================
platform win32 -- Python 3.6.8, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\bruno\hooksample
collected 1 item

src\pyi_hooksample\__pyinstaller\t\test_hooksample_packaging.py . [100%]

========================= warnings summary ==========================
src/pyi_hooksample/__pyinstaller/t/test_hooksample_packaging.py::test_pyi_hooksample
  C:\Users\bruno\hooksample\.env36\lib\site-packages\PyInstaller\lib\modulegraph\util.py:4: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=================== 1 passed, 1 warning in 4.81s ====================

Becomes:

位 python -m pytest src -ra --lean-terminal
======================== test session starts ========================
collected 1 item

src\pyi_hooksample\__pyinstaller\t\test_hooksample_packaging.py . [100%]

=================== 1 passed, 1 warning in 4.81s ====================

How about a --lean-terminal or something which only skips both header and summary?

What about --no-header, for something explicit?

The summary gets skipped by default (except for warnings being on there by default), but -rN (or -r-w etc) would skip it there then (#6454).

What about --no-header, for something explicit?

I'm using this suggestion in case we go for #6454 and the summary gets shown by default, but you are right that if -rN is a thing probably --no-header is better.

6454 needs a way to disable it.

And I agree with you that it would be good to have a single option for it ("--lean-terminal"), but also think that it makes sense to have an option to skip the header by itself explicitly.
So instead of -rN we could also have --no-summary as a long option for clarity (but -rN would make sense still).

If we can find a good/better name for --lean-terminal that would then be a shortcut for --no-header --no-summary.

Agree. 馃憤

As both a user and a maintainer, it's occasionally but very very useful to be able to see what version of Python, pytest, and plugins are running. IMO it's not worth endangering this to save just two lines of space in the terminal!

@Zac-HD
Do you mean we should not have --no-header?

Otherwise I agree with the usefulness of the information, and thought that we should e.g. include the header (the version information) with e.g. something like --version -v.

That's correct, I'm a -.5 on this change because I find the header very useful in bug reports and don't think omitting it is very helpful.

I also have a general preference for less config options, because the more we add the harder it becomes to learn pytest or to write exhaustive self-tests and reliable plugins.

I find the header very useful in bug reports and don't think omitting it is very helpful.

Ok. Keep in mind though that it is not enabled by default (and users using it on purpose would be the same as not pasting the header then).
We might even allow for keeping crucial parts of the header with -q then maybe even (given that there is a way to skip it explicitly).

Ok. Keep in mind though that it is not enabled by default

Yeah that's important, I agree the header should be on by default.

Was this page helpful?
0 / 5 - 0 ratings