Skip to content

Commit 4a1970d

Browse files
committed
MNT: Avoid using deprecated remove_text
Matplotlib 2.1 deprecated the remove_text staticmethod on ImageComparisonTest. Try to use the standalone function, and fallback to the method as needed.
1 parent b7e2fca commit 4a1970d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest_mpl/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def pytest_runtest_setup(self, item):
129129
import matplotlib.pyplot as plt
130130
from matplotlib.testing.compare import compare_images
131131
from matplotlib.testing.decorators import ImageComparisonTest as MplImageComparisonTest
132+
try:
133+
from matplotlib.testing.decorators import remove_ticks_and_titles
134+
except ImportError:
135+
remove_ticks_and_titles = MplImageComparisonTest.remove_text
132136

133137
MPL_LT_15 = LooseVersion(matplotlib.__version__) < LooseVersion('1.5')
134138

@@ -178,7 +182,7 @@ def item_function_wrapper(*args, **kwargs):
178182
fig = original(*args, **kwargs)
179183

180184
if remove_text:
181-
MplImageComparisonTest.remove_text(fig)
185+
remove_ticks_and_titles(fig)
182186

183187
# Find test name to use as plot name
184188
filename = compare.kwargs.get('filename', None)

0 commit comments

Comments
 (0)