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

Html report not generated if logs include unicode character

Open rafi4135 opened this issue 2 years ago • 10 comments

This test does not generate html report:

def test_encode(self):
       var = "just random print:"+"'\u200e'"        
       print(var)

But this test does:

def test_encode(self):
       var = "just random print:"+"'\u200e'"
       var = str(var.encode('utf-8'))
       print(var)

Is there any way to handle this from conftest.py? so that explicit encoding is not needed in every print statements?

rafi4135 avatar May 16 '23 10:05 rafi4135

What version are you using? Please try 4.0.0rc4

BeyondEvil avatar May 16 '23 11:05 BeyondEvil

What version are you using? Please try 4.0.0rc4

my pytest version: 7.3.1 my pytest_html version: 3.2.0

rafi4135 avatar May 16 '23 11:05 rafi4135

Please try 4.0.0rc4 and see if the issue remains.

BeyondEvil avatar May 16 '23 11:05 BeyondEvil

Please try 4.0.0rc4 and see if the issue remains.

In this version, the issue is resolved. But the hyperlink to html file doesn't work. Can't click on the link to open the html file from console

rafi4135 avatar May 16 '23 13:05 rafi4135

Please try 4.0.0rc4 and see if the issue remains.

In this version, the issue is resolved. But the hyperlink to html file doesn't work. Can't click on the link to open the html file from console

Interesting. What OS are you using?

Do you get an error? Does the wrong page load? Some more info would be great.

It works for me on Mac.

Can you share a screenshot of the link or similar? Also what params are you sending in to pytest? Are you using any variable expansions or similar?

BeyondEvil avatar May 16 '23 15:05 BeyondEvil

I am using pytest in windows. The correct link shows. If I copy the link and paste it in browser, it opens the correct html file. But I can't directly click on the link on pycharm console. Can't post screenshot due to company policy. But I see, the difference from 3.2.0 version is, it shows path with '\' file separator whereas previous one was '/'

rafi4135 avatar May 17 '23 04:05 rafi4135

This is what I'm seeing on Windows: Generated html report: file://D:\a\pytest-html\pytest-html\.tox\py3.9\log\report.html

Is yours different?

BeyondEvil avatar May 17 '23 06:05 BeyondEvil

Oh, I see now. In the legacy version the printed path was POSIX and not Windows: file:///D:/a/pytest-html/pytest-html/.tox/py38-cov/log/report.html

The question then becomes, which is the correct one.

Are you using WSL? What console/terminal are you using? What IDE?

There are multiple use-cases here and I just want to make sure we get it correct.

Unfortunately I use an M1 Mac which means I can't run Windows on it.

BeyondEvil avatar May 17 '23 06:05 BeyondEvil

I am using windows 10 pro 22H2 version and pycharm IDE 2021.3.2 version's terminal

rafi4135 avatar May 17 '23 09:05 rafi4135

This is what I'm seeing on Windows: Generated html report: file://D:\a\pytest-html\pytest-html\.tox\py3.9\log\report.html

Is yours different?

Mine is same like this in rc4 version. Can you click on the link?

rafi4135 avatar May 17 '23 09:05 rafi4135