Revision: 7665
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7665&view=rev
Author: astraw
Date: 2009-09-06 22:46:00 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
testing: baseline images now in svn. specify image names without '.png'
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/testing/decorators.py
trunk/matplotlib/lib/matplotlib/tests/test_spines.py
trunk/matplotlib/setup.py
Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-09-06
22:45:48 UTC (rev 7664)
+++ trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-09-06
22:46:00 UTC (rev 7665)
@@ -1,8 +1,8 @@
from matplotlib.testing.noseclasses import KnownFailureTest, \
KnownFailureDidNotFailTest, ImageComparisonFailure
-import sys
+import os, sys
import nose
-from matplotlib.cbook import get_sample_data
+import matplotlib.tests
from matplotlib.testing.compare import compare_images
def knownfailureif(fail_condition, msg=None):
@@ -36,7 +36,7 @@
return nose.tools.make_decorator(f)(failer)
return known_fail_decorator
-def image_comparison(baseline_images=None, tol=1e-3):
+def image_comparison(baseline_images=None):
"""
compare images generated by the test with those specified in
*baseline_images*, which must correspond within tolerance *tol*,
@@ -49,10 +49,22 @@
def compare_images_decorator(func):
def decorated_compare_images(*args,**kwargs):
result = func(*args,**kwargs)
+ extension = '.png' # TODO: test more backends
for fname in baseline_images:
- actual = fname
- expected = get_sample_data('test_baseline_%s'%fname,
- asfileobj=False)
+ actual = fname + extension
+
+ # compute filename for baseline image
+ module_name = func.__module__
+ mods = module_name.split('.')
+ assert mods.pop(0)=='matplotlib'
+ assert mods.pop(0)=='tests'
+ subdir = '/'.join(mods)
+ basedir = os.path.dirname(matplotlib.tests.__file__)
+ baseline_dir = os.path.join(basedir,'baseline_images',subdir)
+ expected = os.path.join(baseline_dir,fname) + extension
+
+ # compare the images
+ tol=1e-3 # default tolerance
err = compare_images( expected, actual, tol,
in_decorator=True )
if err:
Modified: trunk/matplotlib/lib/matplotlib/tests/test_spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_spines.py 2009-09-06
22:45:48 UTC (rev 7664)
+++ trunk/matplotlib/lib/matplotlib/tests/test_spines.py 2009-09-06
22:46:00 UTC (rev 7665)
@@ -3,7 +3,7 @@
from matplotlib.testing.decorators import image_comparison
import matplotlib.pyplot as plt
-...@image_comparison(baseline_images=['spines_axes_positions.png'])
+...@image_comparison(baseline_images=['spines_axes_positions'])
def test_spines_axes_positions():
# SF bug 2852168
fig = plt.figure()
@@ -18,4 +18,4 @@
ax.xaxis.set_ticks_position('top')
ax.spines['left'].set_color('none')
ax.spines['bottom'].set_color('none')
- fig.savefig('spines_axes_positions.png')
+ fig.savefig('spines_axes_positions')
Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py 2009-09-06 22:45:48 UTC (rev 7664)
+++ trunk/matplotlib/setup.py 2009-09-06 22:46:00 UTC (rev 7665)
@@ -101,6 +101,18 @@
'backends/Matplotlib.nib/*',
]}
+if 1:
+ # TODO: exclude these when making release?
+ baseline_images = glob.glob(os.path.join('lib','matplotlib','tests',
+ 'baseline_images','*','*'))
+ def chop_package(fname):
+ badstr = os.path.join('lib','matplotlib','')
+ assert fname.startswith(badstr)
+ result = fname[ len(badstr): ]
+ return result
+ baseline_images = [chop_package(f) for f in baseline_images]
+ package_data['matplotlib'].extend(baseline_images)
+
if not check_for_numpy():
sys.exit(1)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins