Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f803777

Browse files
authored
Merge pull request #14419 from anntzer/imshowpilpath
Fix test_imshow_pil on Windows.
2 parents 59d2df7 + 7930b43 commit f803777

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,17 @@ def test_image_python_io():
119119
def test_imshow_pil(fig_test, fig_ref):
120120
style.use("default")
121121
PIL = pytest.importorskip("PIL")
122-
png_path = Path(__file__).parent / "baseline_images/pngsuite/basn3p04.png"
123-
tiff_path = Path(__file__).parent / "baseline_images/test_image/uint16.tif"
122+
# Pillow<=6.0 fails to open pathlib.Paths on Windows (pillow#3823), and
123+
# Matplotlib's builtin png opener doesn't handle them either.
124+
png_path = str(
125+
Path(__file__).parent / "baseline_images/pngsuite/basn3p04.png")
126+
tiff_path = str(
127+
Path(__file__).parent / "baseline_images/test_image/uint16.tif")
124128
axs = fig_test.subplots(2)
125129
axs[0].imshow(PIL.Image.open(png_path))
126130
axs[1].imshow(PIL.Image.open(tiff_path))
127131
axs = fig_ref.subplots(2)
128-
axs[0].imshow(plt.imread(str(png_path)))
132+
axs[0].imshow(plt.imread(png_path))
129133
axs[1].imshow(plt.imread(tiff_path))
130134

131135

0 commit comments

Comments
 (0)