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

No log output captured in my Pytest HTML report

Open nnvkkumar2017 opened this issue 4 years ago • 53 comments

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 Capture

nnvkkumar2017 avatar Feb 09 '21 08:02 nnvkkumar2017

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

kotavi avatar Feb 09 '21 23:02 kotavi

I'm a bit tied up with work lately but perhaps @BeyondEvil or @ssbarnea could assist if they have time

gnikonorov avatar Feb 10 '21 01:02 gnikonorov

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 avatar Feb 12 '21 09:02 fenchu

@fenchu --capture=tee-sys helped, thank you!

kotavi avatar Feb 22 '21 14:02 kotavi

@fenchu --capture=tee-sys helped, thank you!

shariquealam avatar Mar 30 '21 06:03 shariquealam

Thank you, i just removed -s and it helps me.

namigm avatar Feb 02 '22 17:02 namigm

Thanks, i removed -s and it's useful.

kisscelia avatar Apr 14 '22 00:04 kisscelia

Thanks, i removed -s and it's useful.

martvardanian avatar Jun 16 '22 08:06 martvardanian

yes its working fine when i was remove -s.

RajuRekadi avatar Jul 15 '22 12:07 RajuRekadi

while copying or moving the report.htm to other folder the html styling gets broken every time image

Sandeepjiqvia avatar Aug 08 '22 13:08 Sandeepjiqvia

command used was pytest -n 5 html=report.html

Sandeepjiqvia avatar Aug 08 '22 13:08 Sandeepjiqvia

command used was pytest -n 5 html=report.html

Yes, you have to also move the assets folder.

Or run with ”—self-contained-html”

BeyondEvil avatar Aug 08 '22 18:08 BeyondEvil

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 avatar Aug 26 '22 20:08 lefty1975

@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 avatar Aug 26 '22 20:08 BeyondEvil

@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.

lefty1975 avatar Aug 26 '22 20:08 lefty1975

Hi, just got the same issue on pytest-html==3.2.0, was this fixed?

kleinyonatan avatar Oct 26 '22 12:10 kleinyonatan

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.

BeyondEvil avatar Oct 26 '22 12:10 BeyondEvil

Log output seems like a core feature that is currently broken, fixing this might make sense as bug fix to v3 instead of v4 ?

danielbraun89 avatar Jan 14 '23 11:01 danielbraun89

4.0.0rc0 out now, please test if this is still a problem!

BeyondEvil avatar Mar 06 '23 17:03 BeyondEvil

@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.

reports.zip

lefty1975 avatar Mar 07 '23 14:03 lefty1975

@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.

reports.zip

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 🙏

BeyondEvil avatar Mar 07 '23 15:03 BeyondEvil

My apologies, that was poor reporting back on my part.

I will provide clearer details soon.

lefty1975 avatar Mar 07 '23 16:03 lefty1975

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"

ad_ 2023-03-07 at 11 19 01 AM

Please let me know if more details are needed.

lefty1975 avatar Mar 07 '23 16:03 lefty1975

Can you check if the browser console has any warnings/errors? (right click -> inspect or something like that)

BeyondEvil avatar Mar 07 '23 19:03 BeyondEvil

Can you also try with only the --html=report.html flag and then add the --self-contained-html one?

BeyondEvil avatar Mar 07 '23 19:03 BeyondEvil

I will check for any warnings/errors and run with the flags as outlined.

lefty1975 avatar Mar 07 '23 19:03 lefty1975

@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.

lefty1975 avatar Mar 08 '23 14:03 lefty1975

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!

BeyondEvil avatar Mar 08 '23 17:03 BeyondEvil

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.

ssbarnea avatar Mar 08 '23 17:03 ssbarnea

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.

BeyondEvil avatar Mar 10 '23 14:03 BeyondEvil