Skip to content

Commit

Permalink
Chore: Support legacy pytest-metadata (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeyondEvil authored Aug 13, 2023
1 parent cd28210 commit a5e92c2
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit a5e92c2

Please sign in to comment.