Skip to content

Commit

Permalink
MNT: Compat with pytest 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Jan 6, 2024
1 parent 068fc1d commit ed0c6a4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pytest_mpl/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
{actual_path}"""

PYTEST_LT_7 = Version(pytest.__version__) < Version("7.0.0")
PYTEST_GE_8_0 = any([_pytest_version.is_devrelease,
_pytest_version.is_prerelease,
_pytest_version >= Version('8.0')])

# The following are the subsets of formats supported by the Matplotlib image
# comparison machinery
Expand Down Expand Up @@ -128,11 +131,19 @@ def wrapper(*args, **kwargs):
item.obj = figure_interceptor(plugin, item.obj)


def pytest_report_header(config, startdir):
import matplotlib
import matplotlib.ft2font
return ["Matplotlib: {0}".format(matplotlib.__version__),
"Freetype: {0}".format(matplotlib.ft2font.__freetype_version__)]
if PYTEST_GE_8_0:
def pytest_report_header(config, start_path):
import matplotlib
import matplotlib.ft2font
return ["Matplotlib: {0}".format(matplotlib.__version__),
"Freetype: {0}".format(matplotlib.ft2font.__freetype_version__)]

else:
def pytest_report_header(config, startdir):
import matplotlib
import matplotlib.ft2font
return ["Matplotlib: {0}".format(matplotlib.__version__),
"Freetype: {0}".format(matplotlib.ft2font.__freetype_version__)]


def pytest_addoption(parser):
Expand Down

0 comments on commit ed0c6a4

Please sign in to comment.