8000 MNT: Compat with pytest 8.1 · matplotlib/pytest-mpl@8d330ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d330ec

Browse files
committed
MNT: Compat with pytest 8.1
1 parent a6b1319 commit 8d330ec

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

pytest_mpl/plugin.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
{actual_path}"""
5959

6060
PYTEST_LT_7 = Version(pytest.__version__) < Version("7.0.0")
61+
PYTEST_GE_8_0 = any([_pytest_version.is_devrelease,
62+
_pytest_version.is_prerelease,
63+
_pytest_version >= Version('8.0')])
6164

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

130133

131-
def pytest_report_header(config, startdir):
132-
import matplotlib
133-
import matplotlib.ft2font
134-
return ["Matplotlib: {0}".format(matplotlib.__version__),
135-
"Freetype: {0}".format(matplotlib.ft2font.__freetype_version__)]
134+
if PYTEST_GE_8_0:
135+
def pytest_report_header(config, start_path):
136+
import matplotlib
137+
import matplotlib.ft2font
138+
return ["Matplotlib: {0}".format(matplotlib.__version__),
139+
"Freetype: {0}".format(matplotlib.ft2font.__freetype_version__)]
140+
141+
else:
142+
def pytest_report_header(config, startdir):
143+
import matplotlib
144+
import matplotlib.ft2font
145+
return ["Matplotlib: {0}".format(matplotlib.__version__),
146+
"Freetype: {0}".format(matplotlib.ft2font.__freetype_version__)]
136147

137148

138149
def pytest_addoption(parser):

0 commit comments

Comments
 (0)
0