pytest-dev / pytest-dev/pytest-html

Ability to find the report location from within tests? (To ensure images are located correctly)

Open
#824 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I see that when adding an image with a relative path, it needs to be relative to the output report HTML.

From the command line, it's possible to run e.g. pytest --html ../report.html - is there any way to be able to get this path from within a test? That would allow me to save images to an appropriate relative path.

(I can't use absolute paths as I want to be able to copy the report & its assets to CI)

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

Start by tracing how the command-line report path is handled by the pytest plugin and how test code can access plugin state. Define an exposed path that remains useful when the report and its assets are copied together, then verify the behavior with a test covering a relative image path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.