Browse files

Change generated filenames. Put the phrases "expected" and "failed-di…

…ff" toward the end of the filename so files are more appropriately grouped when viewed in file managers and thumbnail tools (eg. gthumb)
  • Loading branch information...
1 parent 606ca15 commit b58aa94160ea98bde97edb6ec0d17a905760162b @mdboom committed Apr 17, 2012
Showing with 16 additions and 5 deletions.
  1. +10 −2 lib/matplotlib/testing/compare.py
  2. +6 −3 lib/matplotlib/testing/decorators.py
View
12 lib/matplotlib/testing/compare.py
@@ -28,6 +28,15 @@
]
#-----------------------------------------------------------------------
+
+def make_test_filename(fname, purpose):
+ """
+ Make a new filename by inserting `purpose` before the file's
+ extension.
+ """
+ base, ext = os.path.splitext(fname)
+ return '%s-%s%s' % (base, purpose, ext)
+
def compare_float( expected, actual, relTol = None, absTol = None ):
"""Fail if the floating point values are not close enough, with
the givem message.
@@ -232,8 +241,7 @@ def compare_images( expected, actual, tol, in_decorator=False ):
rms += np.sum(np.power((h1h-h2h), 2))
rms = np.sqrt(rms / (256 * 3))
- diff_image = os.path.join(os.path.dirname(actual),
- 'failed-diff-'+os.path.basename(actual))
+ diff_image = make_test_filename(actual, 'failed-diff')
if ( (rms / 10000.0) <= tol ):
if os.path.exists(diff_image):
View
9 lib/matplotlib/testing/decorators.py
@@ -9,7 +9,8 @@
from matplotlib import pyplot as plt
from matplotlib import ft2font
import numpy as np
-from matplotlib.testing.compare import comparable_formats, compare_images
+from matplotlib.testing.compare import comparable_formats, compare_images, \
+ make_test_filename
import warnings
def knownfailureif(fail_condition, msg=None, known_exception_class=None ):
@@ -114,7 +115,8 @@ def test(self):
orig_expected_fname = os.path.join(baseline_dir, baseline) + '.' + extension
if extension == 'eps' and not os.path.exists(orig_expected_fname):
orig_expected_fname = os.path.join(baseline_dir, baseline) + '.pdf'
- expected_fname = os.path.join(result_dir, 'expected-' + os.path.basename(orig_expected_fname))
+ expected_fname = make_test_filename(os.path.join(
+ result_dir, os.path.basename(orig_expected_fname)), 'expected')
actual_fname = os.path.join(result_dir, baseline) + '.' + extension
if os.path.exists(orig_expected_fname):
shutil.copyfile(orig_expected_fname, expected_fname)
@@ -128,7 +130,8 @@ def test(self):
def do_test():
figure.savefig(actual_fname)
- err = compare_images(expected_fname, actual_fname, self._tol, in_decorator=True)
+ err = compare_images(expected_fname, actual_fname,
+ self._tol, in_decorator=True)
try:
if not os.path.exists(expected_fname):

0 comments on commit b58aa94

Please sign in to comment.