Skip to content

Commit 45d3877

Browse files
authored
Merge pull request #17617 from anntzer/figeq
Rewrite pdf test to use check_figures_equal.
2 parents c4a46b8 + 6939c21 commit 45d3877

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import matplotlib as mpl
1212
from matplotlib import dviread, pyplot as plt, checkdep_usetex, rcParams
1313
from matplotlib.backends.backend_pdf import PdfPages
14-
from matplotlib.testing.compare import compare_images
15-
from matplotlib.testing.decorators import image_comparison
14+
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1615

1716

1817
needs_usetex = pytest.mark.skipif(
@@ -245,16 +244,13 @@ def psfont(*args, **kwargs):
245244

246245

247246
@pytest.mark.style('default')
248-
def test_pdf_savefig_when_color_is_none(tmpdir):
249-
fig, ax = plt.subplots()
250-
plt.axis('off')
251-
ax.plot(np.sin(np.linspace(-5, 5, 100)), 'v', c='none')
252-
actual_image = tmpdir.join('figure.pdf')
253-
expected_image = tmpdir.join('figure.eps')
254-
fig.savefig(str(actual_image), format='pdf')
255-
fig.savefig(str(expected_image), format='eps')
256-
result = compare_images(str(actual_image), str(expected_image), 0)
257-
assert result is None
247+
@check_figures_equal(extensions=["pdf", "eps"])
248+
def test_pdf_eps_savefig_when_color_is_none(fig_test, fig_ref):
249+
ax_test = fig_test.add_subplot()
250+
ax_test.set_axis_off()
251+
ax_test.plot(np.sin(np.linspace(-5, 5, 100)), "v", c="none")
252+
ax_ref = fig_ref.add_subplot()
253+
ax_ref.set_axis_off()
258254

259255

260256
@needs_usetex

0 commit comments

Comments
 (0)