@@ -63,7 +63,7 @@ def _download_file(baseline, filename):
6363 try :
6464 u = urlopen (base_url + filename )
6565 content = u .read ()
66- except Exception as exc :
66+ except Exception :
6767 warnings .warn ('Downloading {0} failed' .format (base_url + filename ))
6868 else :
6969 break
@@ -104,7 +104,9 @@ def pytest_addoption(parser):
104104
105105def pytest_configure (config ):
106106
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" )
108110
109111 if config .getoption ("--mpl" ) or config .getoption ("--mpl-generate-path" ) is not None :
110112
@@ -269,21 +271,26 @@ def item_function_wrapper(*args, **kwargs):
269271 if baseline_remote :
270272 baseline_image_ref = _download_file (baseline_dir , filename )
271273 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 ))
273276
274277 if not os .path .exists (baseline_image_ref ):
275278 pytest .fail ("Image file not found for comparison test in: "
276279 "\n \t {baseline_dir}"
277280 "\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 )
279284
280285 # distutils may put the baseline images in non-accessible places,
281286 # 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 ))
283289 shutil .copyfile (baseline_image_ref , baseline_image )
284290
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
287294 expected_shape = Image .open (baseline_image ).size
288295 actual_shape = Image .open (test_image ).size
289296 if expected_shape != actual_shape :
@@ -305,7 +312,8 @@ def item_function_wrapper(*args, **kwargs):
305312 if not os .path .exists (self .generate_dir ):
306313 os .makedirs (self .generate_dir )
307314
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 )
309317 close_mpl_figure (fig )
310318 pytest .skip ("Skipping test, since generating data" )
311319
@@ -331,8 +339,6 @@ def pytest_runtest_setup(self, item):
331339 if compare is None :
332340 return
333341
334- import matplotlib .pyplot as plt
335-
336342 original = item .function
337343
338344 @wraps (item .function )
0 commit comments