Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e53cb0e

Browse filesBrowse files
authored
Merge pull request #10222 from anntzer/link
Use symlinks instead of copies for test result_images.
2 parents f68b4ea + 6d8bc9f commit e53cb0e
Copy full SHA for e53cb0e

File tree

Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-7
lines changed

‎lib/matplotlib/testing/decorators.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/decorators.py
+12-7Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,18 @@ def copy_baseline(self, baseline, extension):
192192
os.path.join(self.result_dir,
193193
os.path.basename(orig_expected_fname)),
194194
'expected')
195-
if os.path.exists(orig_expected_fname):
196-
shutil.copyfile(orig_expected_fname, expected_fname)
197-
else:
198-
reason = ("Do not have baseline image {} because this "
199-
"file does not exist: {}".format(expected_fname,
200-
orig_expected_fname))
201-
raise ImageComparisonFailure(reason)
195+
try:
196+
# os.symlink errors if the target already exists.
197+
with contextlib.suppress(OSError):
198+
os.remove(expected_fname)
199+
try:
200+
os.symlink(orig_expected_fname, expected_fname)
201+
except OSError: # On Windows, symlink *may* be unavailable.
202+
shutil.copyfile(orig_expected_fname, expected_fname)
203+
except OSError:
204+
raise ImageComparisonFailure(
205+
f"Missing baseline image {expected_fname} because the "
206+
f"following file cannot be accessed: {orig_expected_fname}")
202207
return expected_fname
203208

204209
def compare(self, idx, baseline, extension):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.