Revision: 7702 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7702&view=rev Author: astraw Date: 2009-09-07 20:56:27 +0000 (Mon, 07 Sep 2009)
Log Message: ----------- testing: fix image_comparison decorator to guess image location when test run as script 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-09-07 20:56:17 UTC (rev 7701) +++ trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-09-07 20:56:27 UTC (rev 7702) @@ -55,11 +55,19 @@ # 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__) + if module_name=='__main__': + # FIXME: this won't work for nested packages in matplotlib.tests + import warnings + warnings.warn('test module run as script. guessing baseline image locations') + script_name = sys.argv[0] + basedir = os.path.abspath(os.path.dirname(script_name)) + subdir = os.path.splitext(os.path.split(script_name)[1])[0] + else: + mods = module_name.split('.') + assert mods.pop(0)=='matplotlib' + assert mods.pop(0)=='tests' + subdir = os.path.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 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 Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins