From 7930b43793273e64726fc970b9919257bf215c85 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 2 Jun 2019 21:22:26 +0200 Subject: [PATCH] Fix test_imshow_pil on Windows. test_imshow_pil currently fails on Windows, but this was not detected because PIL is not installed on the Appveyor CI so the test is skipped. --- lib/matplotlib/tests/test_image.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 065de4ee207d..fd0479ca9cf0 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -119,13 +119,17 @@ def test_image_python_io(): def test_imshow_pil(fig_test, fig_ref): style.use("default") PIL = pytest.importorskip("PIL") - png_path = Path(__file__).parent / "baseline_images/pngsuite/basn3p04.png" - tiff_path = Path(__file__).parent / "baseline_images/test_image/uint16.tif" + # Pillow<=6.0 fails to open pathlib.Paths on Windows (pillow#3823), and + # Matplotlib's builtin png opener doesn't handle them either. + png_path = str( + Path(__file__).parent / "baseline_images/pngsuite/basn3p04.png") + tiff_path = str( + Path(__file__).parent / "baseline_images/test_image/uint16.tif") axs = fig_test.subplots(2) axs[0].imshow(PIL.Image.open(png_path)) axs[1].imshow(PIL.Image.open(tiff_path)) axs = fig_ref.subplots(2) - axs[0].imshow(plt.imread(str(png_path))) + axs[0].imshow(plt.imread(png_path)) axs[1].imshow(plt.imread(tiff_path))