pytest-xdist icon indicating copy to clipboard operation
pytest-xdist copied to clipboard

Suppress header output

Open xixixao opened this issue 1 year ago • 5 comments

Is there any way to suppress this output at the start of pytest -n auto? -q has no output.

[gw0] darwin Python 3.9.17 cwd: /some/path
[gw1] darwin Python 3.9.17 cwd: /some/path
[gw2] darwin Python 3.9.17 cwd: /some/path
[gw3] darwin Python 3.9.17 cwd: /some/path
[gw4] darwin Python 3.9.17 cwd: /some/path
[gw5] darwin Python 3.9.17 cwd: /some/path
[gw6] darwin Python 3.9.17 cwd: /some/path
[gw7] darwin Python 3.9.17 cwd: /some/path
[gw8] darwin Python 3.9.17 cwd: /some/path
[gw9] darwin Python 3.9.17 cwd: /some/path
[gw0] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw1] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw2] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw3] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw4] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw6] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw5] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw7] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
[gw8] Python 3.9.17 (main, Jun 12 2023, 14:44:48)  -- [Clang 14.0.3 (clang-1403.0.22.14.1)]
gw0 [2] / gw1 [2] / gw2 [2] / gw3 ok / gw4 ok / gw5 ok / gw6 ok / gw7 ok / gw8 ok / gw9 gw0 [2] / gw1 [2] / gw2 [2] / gw3 [2] / gw4 ok / gw5 ok / gw6 ok / gw7 ok / gw8 ok / gw9

This is a large log spew that is irrelevant to the user running the test.

I tried searching through the issues here and docs, but couldn't find a way that would suppress this output.

xixixao avatar Oct 23 '23 18:10 xixixao

Hi,

3.3.0 has changed the output so it less verbose, please upgrade.

nicoddemus avatar Oct 24 '23 11:10 nicoddemus

Hey @nicoddemus, thanks, that's a big improvement! Any way we can configure the preambule output to be omitted entirely?

It still prints

10 workers [2 items]
scheduling tests via LoadScheduling

xixixao avatar Oct 24 '23 21:10 xixixao

Not currently...

What exactly would you like to omit? Can you show the normal output and mark the lines (perhaps prefixing them with - or some other character) you would like to see omitted?

nicoddemus avatar Oct 25 '23 17:10 nicoddemus

Using pytest --no-header -vv

============================= test session starts ==============================
collected 211 items / 209 deselected / 2 selected

test_foo.py::test_foo PASSED              [ 50%]
test_foo.py::test_bla PASSED               [100%]

====================== 2 passed, 209 deselected in 24.99s ======================

Using pytest --no-header -vv -n auto

Currently:

============================= test session starts ==============================
10 workers [2 items]
scheduling tests via LoadScheduling

test_foo.py::test_foo
test_foo.py::test_bla
[gw1] [ 50%] PASSED test_foo.py::test_bla
[gw0] [100%] PASSED test_foo.py::test_foo

============================== 2 passed in 33.25s ==============================

Desired:

============================= test session starts ==============================
collected 211 items / 209 deselected / 2 selected

test_foo.py::test_foo
test_foo.py::test_bla
[gw1] [ 50%] PASSED test_foo.py::test_bla
[gw0] [100%] PASSED test_foo.py::test_foo

============================== 2 passed in 33.25s ==============================

I'm assuming the duplicate test line is inevitable because of the concurrency of the print outs, so I'm only concerned with the plugin "header".

xixixao avatar Oct 25 '23 19:10 xixixao

I'm not sure how easy it is to print the collected 211 items / 209 deselected / 2 selected line with xdist, as the collection is done by workers, but suppressing the "x workers" and "scheduling tests" lines seem simple, we just need to consider the --no-header option in xdist.

Would be happy to review/merge a PR with that, if anybody wants to contribute.

nicoddemus avatar Oct 26 '23 12:10 nicoddemus