@@ -63,7 +63,7 @@ def _download_file(baseline, filename):
63
63
try :
64
64
u = urlopen (base_url + filename )
65
65
content = u .read ()
66
- except Exception as exc :
66
+ except Exception :
67
67
warnings .warn ('Downloading {0} failed' .format (base_url + filename ))
68
68
else :
69
69
break
@@ -104,7 +104,9 @@ def pytest_addoption(parser):
104
104
105
105
def pytest_configure (config ):
106
106
107
- config .addinivalue_line ('markers' , "mpl_image_compare: Compares matplotlib figures against a baseline image" )
107
+ config .addinivalue_line ('markers' ,
108
+ "mpl_image_compare: Compares matplotlib figures "
109
+ "against a baseline image" )
108
110
109
111
if config .getoption ("--mpl" ) or config .getoption ("--mpl-generate-path" ) is not None :
110
112
@@ -269,21 +271,26 @@ def item_function_wrapper(*args, **kwargs):
269
271
if baseline_remote :
270
272
baseline_image_ref = _download_file (baseline_dir , filename )
271
273
else :
272
- baseline_image_ref = os .path .abspath (os .path .join (os .path .dirname (item .fspath .strpath ), baseline_dir , filename ))
274
+ baseline_image_ref = os .path .abspath (os .path .join (
275
+ os .path .dirname (item .fspath .strpath ), baseline_dir , filename ))
273
276
274
277
if not os .path .exists (baseline_image_ref ):
275
278
pytest .fail ("Image file not found for comparison test in: "
276
279
"\n \t {baseline_dir}"
277
280
"\n (This is expected for new tests.)\n Generated Image: "
278
- "\n \t {test}" .format (baseline_dir = baseline_dir , test = test_image ), pytrace = False )
281
+ "\n \t {test}" .format (baseline_dir = baseline_dir ,
282
+ test = test_image ),
283
+ pytrace = False )
279
284
280
285
# distutils may put the baseline images in non-accessible places,
281
286
# copy to our tmpdir to be sure to keep them in case of failure
282
- baseline_image = os .path .abspath (os .path .join (result_dir , 'baseline-' + filename ))
287
+ baseline_image = os .path .abspath (os .path .join (result_dir ,
288
+ 'baseline-' + filename ))
283
289
shutil .copyfile (baseline_image_ref , baseline_image )
284
290
285
- # Compare image size ourselves since the Matplotlib exception is a bit cryptic in this case
286
- # and doesn't show the filenames
291
+ # Compare image size ourselves since the Matplotlib
292
+ # exception is a bit cryptic in this case and doesn't show
293
+ # the filenames
287
294
expected_shape = Image .open (baseline_image ).size
288
295
actual_shape = Image .open (test_image ).size
289
296
if expected_shape != actual_shape :
@@ -305,7 +312,8 @@ def item_function_wrapper(*args, **kwargs):
305
312
if not os .path .exists (self .generate_dir ):
306
313
os .makedirs (self .generate_dir )
307
314
308
- fig .savefig (os .path .abspath (os .path .join (self .generate_dir , filename )), ** savefig_kwargs )
315
+ fig .savefig (os .path .abspath (os .path .join (self .generate_dir , filename )),
316
+ ** savefig_kwargs )
309
317
close_mpl_figure (fig )
310
318
pytest .skip ("Skipping test, since generating data" )
311
319
@@ -331,8 +339,6 @@ def pytest_runtest_setup(self, item):
331
339
if compare is None :
332
340
return
333
341
334
- import matplotlib .pyplot as plt
335
-
336
342
original = item .function
337
343
338
344
@wraps (item .function )
0 commit comments