pytest-html
pytest-html copied to clipboard
No log output captured in my Pytest HTML report
Team, every time if i ran the HTML report in pytest getting below error .No logs are captured in that report.Please help me how to resolve this issue to get captured all the data..I have used below code
pytest -v -s nopecom_testPackage/test_admin_LoginPage.py --html=report.html
I have the same issue when tests are executed in Gitlab pipeline
the command I'm using
python.exe -m pytest -s tests/step_defs/
Versions:
pytest - 6.2.2.
pytest-html - 3.1.1
I'm a bit tied up with work lately but perhaps @BeyondEvil or @ssbarnea could assist if they have time
Before pytest-html v3 the -s seem to have been ignored/overrided (It actually means do not capture), so it works as intended.
You can use --capture=tee-sys If it is too much work changing use pytest-html v2.11
@fenchu --capture=tee-sys helped, thank you!
@fenchu --capture=tee-sys helped, thank you!
Thank you, i just removed -s and it helps me.
Thanks, i removed -s and it's useful.
Thanks, i removed -s and it's useful.
yes its working fine when i was remove -s.
while copying or moving the report.htm to other folder the html styling gets broken every time
command used was pytest -n 5 html=report.html
command used was pytest -n 5 html=report.html
Yes, you have to also move the assets folder.
Or run with ”—self-contained-html”
I'm having issues where I'm not capturing log output details for any of my test runs, failed, passed, error, etc. Is this still an open issue or has it been resolved in a newer version?
I'm currently running 3.1.1
@lefty1975
It's been resolved, but not yet released. I'm working on the final bits as we speak and I'm hoping to release the new version within a week.
Thanks for your patience!
@BeyondEvil stay evil and thank you!
I thought it was me actually. I did not encounter this issue with other projects using the same version on a mac os. It wasn't until I started a new project in a windows environment that this occurred.
Hi, just got the same issue on pytest-html==3.2.0, was this fixed?
Yeah, sorry no. It wasn’t part of the v3 release, it will be part of the v4 one. Which we are currently wrapping up for a RC release.
Log output seems like a core feature that is currently broken, fixing this might make sense as bug fix to v3 instead of v4 ?
4.0.0rc0 out now, please test if this is still a problem!
@BeyondEvil I installed the version specified and ran one of my pytests and the report is not functional. Attached is a compressed file of the end result. Maybe this is something on my end that now needs to be adjusted.
@BeyondEvil I installed the version specified and ran one of my pytests and the report is not functional. Attached is a compressed file of the end result. Maybe this is something on my end that now needs to be adjusted.
Maybe it's obvious once I open the report.
But can you specify what you mean with "not functional"?
Could you also detail how you generate the report? What flags you're passing in, what OS you're on, versions of python, pytest etc.
Thanks 🙏
My apologies, that was poor reporting back on my part.
I will provide clearer details soon.
The generated report does not provide any details about the tests that were executed. The report is practically blank other than some checkboxes, a couple of headers/labels, and this div <div>There are still tests running. <br>Reload this page to ge the latest results!</div>
that consists of an onclick
attribute.
I run my tests either from a terminal or from Pycharm's Community using the run option. I'm on macOS running Ventura 13.2.1 (22D68). And I'm using pipenv
and executed pipenv install pytest-html~=4.0.0rc0
and maybe that's my issue, I didn't upgrade correctly.
The flags I use:
-n1 --reruns 1 --reruns-delay 3 --html=report.html --self-contained-html --cache-clear --slack_hook=[url] --slack_channel=[channel] --slack_username="Results"

Please let me know if more details are needed.
Can you check if the browser console has any warnings/errors? (right click -> inspect or something like that)
Can you also try with only the --html=report.html
flag and then add the --self-contained-html
one?
I will check for any warnings/errors and run with the flags as outlined.
@BeyondEvil I believe I have found the issue and it has to do with https://pypi.org/project/pytest-xdist/
and including the -n
flag. When I leave this flag out the results are as expected. When adding this flag I receive the previously reported behavior and the Console indicates the following error:
Uncaught TypeError: data.tests.map is not a function at DataManager.setManager (03_08_2023_09_23_58.html?_ijt=d3ibr5mqhh258krspnji0vd17m&_ij_reload=RELOAD_ON_SAVE:394:55) at init (03_08_2023_09_23_58.html?_ijt=d3ibr5mqhh258krspnji0vd17m&_ij_reload=RELOAD_ON_SAVE:622:13) at 4../datamanager.js (03_08_2023_09_23_58.html?_ijt=d3ibr5mqhh258krspnji0vd17m&_ij_reload=RELOAD_ON_SAVE:629:1) at o (03_08_2023_09_23_58.html?_ijt=d3ibr5mqhh258krspnji0vd17m&_ij_reload=RELOAD_ON_SAVE:388:271) at r (03_08_2023_09_23_58.html?_ijt=d3ibr5mqhh258krspnji0vd17m&_ij_reload=RELOAD_ON_SAVE:388:437) at 03_08_2023_09_23_58.html?_ijt=d3ibr5mqhh258krspnji0vd17m&_ij_reload=RELOAD_ON_SAVE:388:466
I'm also running the latest version of pytest-xdist
so maybe this is an issue with that library.
Thanks! That's what I expected. Not the error, but that it was pytest-xdist causing it. I don't however think the issue is with that library. I'll investigate. Thank you!
pytest-xdist is one of the most popular pytest plugins, one that we cannot really ignore. I am using it in ~9/10 projects, very few exceptions and those were basically those where it did not make sense due to concurrency constraints.
pytest-xdist is one of the most popular pytest plugins, one that we cannot really ignore. I am using it in ~9/10 projects, very few exceptions and those were basically those where it did not make sense due to concurrency constraints.
I've found the issue.
I've tagged you on 3 different proposed solutions.