pytest-dev / pytest-dev/pytest-html

links generated in the html file for attachments are absolute, there is no way to make them relative

Open
#309 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
779
Forks
260
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with a PNG attachment using the example in the issue, then inspect the generated HTML and attachment-link handling. Move the HTML file, resource folder, and PNG together and verify that the image still loads; done means the generated link no longer depends on the original absolute path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.