pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Add option to force "short summary" despite high verbosity

Open Delgan opened this issue 6 years ago • 1 comments

Hi!

By "short summary", I mean the following format with dots:

========================= test session starts ==========================
platform linux -- Python 3.7.4, pytest-4.6.2, py-1.8.0, pluggy-0.12.0
rootdir: /home/delgan/Programmation/loguru, inifile: tox.ini
plugins: xdist-1.29.0, forked-1.0.2, cov-2.7.1
collected 1154 items                                                   

tests/test_activation.py ..............................          [  2%]
tests/test_add_option_backtrace.py .                             [  2%]
tests/test_add_option_catch.py ...........                       [  3%]
tests/test_add_option_colorize.py .............................. [  6%]
tests/test_add_option_diagnose.py .                              [  7%]
tests/test_add_option_enqueue.py .........                       [  7%]
tests/test_add_option_filter.py ................................ [ 10%]
tests/test_add_option_format.py ..................               [ 14%]
tests/test_add_option_kwargs.py .......                          [ 14%]
tests/test_add_option_level.py ..........                        [ 15%]
tests/test_add_option_serialize.py ...                           [ 15%]
tests/test_add_sinks.py ...........................FFF.......... [ 19%]
tests/test_ansimarkup_basic.py ................................. [ 23%]
[...]

Versus the verbose one:

============================= test session starts ==============================

platform linux -- Python 3.5.6, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
cachedir: .tox/py35/.pytest_cache
rootdir: /home/travis/build/Delgan/loguru, inifile: tox.ini
plugins: cov-2.7.1
collected 945 items                
                                            
tests/test_activation.py::test_disable[-False] PASSED                      [  0%]
tests/test_activation.py::test_disable[tests-False] PASSED                 [  0%]
tests/test_activation.py::test_disable[test-True] PASSED                   [  0%]
tests/test_activation.py::test_disable[testss-True] PASSED                 [  0%]
tests/test_activation.py::test_disable[tests.-True] PASSED                 [  0%]
tests/test_activation.py::test_disable[tests.test_activation-False] PASSED [  0%]
tests/test_activation.py::test_disable[tests.test_activation.-True] PASSED [  0%]
tests/test_activation.py::test_disable[test_activation-True] PASSED        [  0%]
tests/test_activation.py::test_disable[.-True] PASSED                      [  0%]
tests/test_activation.py::test_enable[-True] PASSED                        [  1%]
[...]

I personally find the short format more convenient: it allows me to run the tests, change screen to do something else, and come back a few dozen seconds later to see if the tests are going well (assuming that the entire session takes a minute or two to run). This allows me to see at a glance if any tests have failed, and if so, in which group there is a problem. In verbose mode, this is not the case, since the tests scroll too fast on the screen, and there is no global view. Yet, the -vv option is essential to see other useful information and avoid output to be truncated in case of failure.

Hence my question: do you think it would make sense to add an option to force the display using dots regardless of the level of verbosity?

I can definitively implement this and open a PR if you find it interesting.

Delgan avatar Nov 30 '19 10:11 Delgan

Yet, the -vv option is essential to see other useful information and avoid output to be truncated in case of failure.

I think this makes sense to address instead (also) probably. For some cases you can use CI=true pytest … already and IIRC I have a separate option in my fork already (to not truncate ever; https://github.com/blueyed/pytest/pull/63).

It might still make sense to have an intermediate terminal output format though of course.. I've experimented myself with just using a single line and only adding new lines with test failures.

btw: by now you should see different colors of the progress bar if any tests failed already.

blueyed avatar Nov 30 '19 16:11 blueyed