kevlened / pytest-parallel

A pytest plugin for parallel and concurrent testing
https://github.com/browsertron/pytest-parallel/issues/104#issuecomment-1293941066
MIT License
313 stars 60 forks source link

stdout mixed between tests in HTML report #23

Open istepanko opened 6 years ago

istepanko commented 6 years ago

So the output is mixed instead of be per test

kevlened commented 6 years ago

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

kevlened commented 6 years ago

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

s1ider commented 6 years ago

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.

kevlened commented 6 years ago

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.

AnilBhubaneswar commented 5 years ago

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

joaoe commented 5 years ago

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

VladimirChernev commented 4 years ago

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.

madhav-pai commented 2 years ago

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

prajwal-naladeega commented 2 years ago

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

mnaumann-plenty commented 2 years ago

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

mnaumann-plenty commented 2 years ago

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