🌐 AI搜索 & 代理 主页
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,18 @@ def copy_baseline(self, baseline, extension):
os.path.join(self.result_dir,
os.path.basename(orig_expected_fname)),
'expected')
if os.path.exists(orig_expected_fname):
shutil.copyfile(orig_expected_fname, expected_fname)
else:
reason = ("Do not have baseline image {} because this "
"file does not exist: {}".format(expected_fname,
orig_expected_fname))
raise ImageComparisonFailure(reason)
try:
# os.symlink errors if the target already exists.
with contextlib.suppress(OSError):
os.remove(expected_fname)
try:
os.symlink(orig_expected_fname, expected_fname)
except OSError: # On Windows, symlink *may* be unavailable.
shutil.copyfile(orig_expected_fname, expected_fname)
except OSError:
raise ImageComparisonFailure(
f"Missing baseline image {expected_fname} because the "
f"following file cannot be accessed: {orig_expected_fname}")
return expected_fname

def compare(self, idx, baseline, extension):
Expand Down