Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/pytest_html/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ def _media_content(self, content, asset_name, *args, **kwargs):
media_data = base64.b64decode(content.encode("utf-8"), validate=True)
return self._write_content(media_data, asset_name)
except binascii.Error:
# if not base64 content, just return as it's a file or link
return content
# if not base64 content, try to make it relative to the report
try:
abs_path = Path(content).resolve()
return str(abs_path.relative_to(self._report_path.parent.resolve()))
except (ValueError, OSError):
# On different drives (Windows) or unresolvable, return as-is
return content

def _write_content(self, content, asset_name):
content_relative_path = Path(self._assets_path, asset_name)
Expand Down