Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/pytest_html/basereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def _generate_environment(self):
warnings.warn(
"'pytest-metadata < 3.0.0' is deprecated and support will be dropped in next major version",
DeprecationWarning,
stacklevel=2,
)

for key in metadata.keys():
Expand Down Expand Up @@ -214,6 +215,7 @@ def pytest_runtest_logreport(self, report):
"'duration_formatter' has been removed and no longer has any effect!"
"Please use the 'pytest_html_duration_format' hook instead.",
DeprecationWarning,
stacklevel=2,
)

# "reruns" makes this code a mess.
Expand Down Expand Up @@ -370,6 +372,7 @@ def _fix_py(cells):
"The 'py' module is deprecated and support "
"will be removed in a future release.",
DeprecationWarning,
stacklevel=2,
)
html = str(html)
html = html.replace("col=", "data-column-type=")
Expand Down
1 change: 1 addition & 0 deletions src/pytest_html/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_foo(extra):
"The 'extra' fixture is deprecated and will be removed in a future release"
", use 'extras' instead.",
DeprecationWarning,
stacklevel=2,
)
pytestconfig.stash[extras_stash_key] = []
yield pytestconfig.stash[extras_stash_key]
Expand Down
1 change: 1 addition & 0 deletions src/pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def pytest_runtest_makereport(item, call):
"The 'report.extra' attribute is deprecated and will be removed in a future release"
", use 'report.extras' instead.",
DeprecationWarning,
stacklevel=2,
)
fixture_extras = item.config.stash.get(extras_stash_key, [])
plugin_extras = getattr(report, "extras", [])
Expand Down
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
1 change: 1 addition & 0 deletions src/pytest_html/report_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, config):
"will be removed in the next major release. "
"Please use 'render_collapsed = all' instead.",
DeprecationWarning,
stacklevel=2,
)
collapsed = "all"

Expand Down
3 changes: 2 additions & 1 deletion src/pytest_html/selfcontained_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def _media_content(self, content, mime_type, *args, **kwargs):
warnings.warn(
"Self-contained HTML report "
"includes link to external "
f"resource: {content}"
f"resource: {content}",
stacklevel=2,
)
return content

Expand Down