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

stdout mixed between tests in HTML report

Open istepanko opened this issue 7 years ago • 11 comments

So the output is mixed instead of be per test

istepanko avatar Oct 24 '18 22:10 istepanko

Interesting. Are you seeing this with --workers or --tests-per-worker?

kevlened avatar Oct 25 '18 00:10 kevlened

Looks like it happens in either scenario. Thanks for reporting!

kevlened avatar Oct 25 '18 00:10 kevlened

Same issue for me. @kevlened you wrote an amazing and very useful plugin, love it. The main issue is that reporting is broken: --junit option causes xml report to be written empty, and pytest-html makes messy report with mixed output from different tests. This makes plug to be impossible to use in production :( Let me know if I can help, I would like to.

s1ider avatar Nov 06 '18 09:11 s1ider

Thanks for the feedback. The --junitxml problem is new to me, but I've created an issue to track it: #24. I also wasn't aware that pytest-html created a messy report. If you can open an issue with a screenshot, that'd be helpful.

kevlened avatar Nov 06 '18 14:11 kevlened

Same issue . I am also facing . Anyone tried any hook or code for temporary fix

AnilBhubaneswar avatar Feb 14 '19 14:02 AnilBhubaneswar

Same goes for STDOUT/STDERR. I tried to hack around a bit with multiprocessing.RLock() but it does not work at all because pytest has its own output capturing code

joaoe avatar May 15 '19 22:05 joaoe

I tried using queues + QueueHandler and QueueListener, and now the html report produced from pytest-html is sorted - I see the correct order of the log messages in the report but its duplicated for each scenario like so: first scenario has the messages for first seenario second scenario has the messages for first scenario and second scenario third scenario has the messages for first scenario, second scenario and third scenario and so on

solution I used is here under section: Dealing with handlers that block https://docs.python.org/3.7/howto/logging-cookbook.html

Im using python 3.8, pytest==5.3.5, pytest-html==2.0.1, pytest-parallel==0.0.10.

VladimirChernev avatar Mar 11 '20 14:03 VladimirChernev

Hi @kevlened - is there any plans to fix this issue

madhav-pai avatar Apr 26 '22 07:04 madhav-pai

Hi @kevlened ,even i'm stuck on this issue as well, any timeline for the fix?

prajwal-naladeega avatar Apr 26 '22 08:04 prajwal-naladeega

I'm experiencing this (in May 2022) as well

mnaumann-plenty avatar May 02 '22 23:05 mnaumann-plenty

On my Ubuntu 21.10 system, I've got Python 3.9.7 (CPython) with:

pytest               7.1.1
pytest-html          3.1.1
pytest-parallel      0.1.1
pytest-xdist         2.5.0

...and this test file:

test_junk.py.zip

...which I run in these two variations:

pytest-xdist:

$ pytest --html=report.html --self-contained-html -n auto test_junk.py


pytest-parallel:

$ pytest --html=report.html --self-contained-html --workers auto test_junk.py

The pytest-xdist run yields this output for test test_junk.py::test_001:

[gw0] linux -- Python 3.9.7 /home/mnaumann/PycharmProjects/Parallelism/venv/bin/python
[gw0] linux -- Python 3.9.7 /home/mnaumann/PycharmProjects/Parallelism/venv/bin/python[gw0] linux -- Python 3.9.7 /home/mnaumann/PycharmProjects/Parallelism/venv/bin/python[gw0] linux -- Python 3.9.7 /home/mnaumann/PycharmProjects/Parallelism/venv/bin/python
 ------------------------------Captured stdout call------------------------------ 
Current test: test_001
Sleeping for 4 seconds...

The pytest-parallel run yields this output for test test_junk.py::test_001:

 ------------------------------Captured stdout call------------------------------ 
Current test: test_006
Sleeping for 2 seconds...

On repeated runs, the pytest-xdist consistently sends test output to the correct individual test report.

The pytest-parallel output is invariably inconsistent. Some individual test reports have the output of several individual tests:

 ------------------------------Captured stdout call------------------------------ 
Current test: test_002
Sleeping for 3 seconds...
Current test: test_003
Sleeping for 4 seconds...
Current test: test_004
Sleeping for 3 seconds...

...while others are empty:

No log output captured.

xdist-v-parallel.zip

mnaumann-plenty avatar May 04 '22 17:05 mnaumann-plenty