From 2f0c67b9ea81b2f8c9f0da72840b740e3db2872b Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 15 May 2023 23:22:17 -0400 Subject: [PATCH] Backport PR #25792: Fix broken symlinks for expected images on WSL --- lib/matplotlib/testing/decorators.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index 483986c74858..4522be395d3e 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -2,6 +2,7 @@ import functools import inspect import os +from platform import uname from pathlib import Path import shutil import string @@ -199,6 +200,8 @@ def copy_baseline(self, baseline, extension): with contextlib.suppress(OSError): os.remove(expected_fname) try: + if 'microsoft' in uname().release.lower(): + raise OSError # On WSL, symlink breaks silently os.symlink(orig_expected_path, expected_fname) except OSError: # On Windows, symlink *may* be unavailable. shutil.copyfile(orig_expected_path, expected_fname)