Skip to content

Chore: Support legacy pytest-metadata #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
14 changes: 12 additions & 2 deletions src/pytest_html/basereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from pathlib import Path

import pytest
from pytest_metadata.plugin import metadata_key

from pytest_html import __version__
from pytest_html import extras
Expand Down Expand Up @@ -66,7 +65,18 @@ def _generate_report(self, self_contained=False):
self._write_report(rendered_report)

def _generate_environment(self):
metadata = self._config.stash[metadata_key]
try:
from pytest_metadata.plugin import metadata_key

metadata = self._config.stash[metadata_key]
except ImportError:
# old version of pytest-metadata
metadata = self._config._metadata
warnings.warn(
"'pytest-metadata < 3.0.0' is deprecated and support will be dropped in next major version",
DeprecationWarning,
)

for key in metadata.keys():
value = metadata[key]
if self._is_redactable_environment_variable(key):
Expand Down