|
From: <as...@us...> - 2009-10-09 17:20:30
|
Revision: 7862
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7862&view=rev
Author: astraw
Date: 2009-10-09 17:20:23 +0000 (Fri, 09 Oct 2009)
Log Message:
-----------
testing: don't compare images if baseline does not exist
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/testing/decorators.py
Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-10-09 16:32:29 UTC (rev 7861)
+++ trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-10-09 17:20:23 UTC (rev 7862)
@@ -4,6 +4,7 @@
import nose
import matplotlib
import matplotlib.tests
+import numpy as np
from matplotlib.testing.compare import comparable_formats, compare_images
def knownfailureif(fail_condition, msg=None):
@@ -58,8 +59,19 @@
def compare_images_generator():
for extension in extensions:
- @knownfailureif(extension not in comparable_formats(),
- 'Cannot compare %s files on this system' % extension)
+ expected_fnames = [os.path.join(baseline_dir,fname) + '.' + extension for fname in baseline_images]
+ actual_fnames = [os.path.join(result_dir, fname) + '.' + extension for fname in baseline_images]
+ have_baseline_images = [os.path.exists(expected) for expected in expected_fnames]
+ have_baseline_image = np.all(have_baseline_images)
+ is_comparable = extension in comparable_formats()
+ if not is_comparable:
+ fail_msg = 'Cannot compare %s files on this system' % extension
+ elif not have_baseline_image:
+ fail_msg = 'Do not have baseline images %s' % expected_fnames
+ else:
+ fail_msg = 'No failure expected'
+ will_fail = not (is_comparable and have_baseline_image)
+ @knownfailureif(will_fail, fail_msg )
def decorated_compare_images():
# set the default format of savefig
matplotlib.rc('savefig', extension=extension)
@@ -70,9 +82,7 @@
result = func() # actually call the test function
finally:
os.chdir(old_dir)
- for fname in baseline_images:
- actual = os.path.join(result_dir, fname) + '.' + extension
- expected = os.path.join(baseline_dir,fname) + '.' + extension
+ for actual,expected in zip(actual_fnames,expected_fnames):
# compare the images
tol=1e-3 # default tolerance
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|