Skip to content

Commit b1b8677

Browse files
committed
MNT: handle creating the metadata json file if needed
1 parent 4d13089 commit b1b8677

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,13 @@ def compare(self, fig, baseline, extension, *, _lock=False):
192192
plt.close(fig)
193193
expected_path = self.copy_baseline(baseline, extension)
194194
# TODO make sure the file exists (and cache?)
195-
with open(self.root_dir / 'metadata.json') as fin:
196-
md = json.load(fin)
195+
json_path = self.root_dir / 'metadata.json'
196+
if json_path.exists():
197+
with open(json_path) as fin:
198+
md = json.load(fin)
199+
else:
200+
md = {}
201+
json_path.parent.mkdir(parents=True, exist_ok=True)
197202
if self.mode == self._ImageCheckMode.GENERATE:
198203
rel_path = expected_path.relative_to(self.root_dir)
199204

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy