pytest-html
pytest-html copied to clipboard
links generated in the html file for attachments are absolute, there is no way to make them relative
Not sure if this is by design or if it is a bug, but if you create a report with attachments like PNG images, the html HREF for those images is the full path.
This has the adverse downside of making reports unusable if you send the report to anyone as zip file, or if you even move the folder where the report and related files are located.
To reproduce:
- Create a generic report, adding a png file extra.append(pytest_html.extras.png("c:\foo\bar\img.png", name="my cool screen")
- Once you launch the html report, it will have the image displayed correctly.
- Move the html file, the resource folder and the png file somewhere else on your machine
- Open the HTML file again
Results:
- the html file will display a broken link for the image. The tag point at the original location so as expected, the image won't display unless the PNG file is in the link location.
I think this is the reason for the adding of the --self-contained-html
flag.
I think this is the reason for the adding of the
--self-contained-html
flag.
That would be acceptable if the output would be able to run anywhere, but when using that flag, it won't run correctly on a different computer.