diff --git a/lib/iris/tests/__init__.py b/lib/iris/tests/__init__.py index 47baf2e409..662299cbe1 100644 --- a/lib/iris/tests/__init__.py +++ b/lib/iris/tests/__init__.py @@ -675,7 +675,7 @@ def _ensure_folder(self, path): logger.warning('Creating folder: %s', dir_path) os.makedirs(dir_path) - def _assert_graphic(self, tol=_HAMMING_DISTANCE): + def check_graphic(self): """ Check the hash of the current matplotlib figure matches the expected image hash for the current graphic test. @@ -734,7 +734,8 @@ def _create_missing(): figure.savefig(hash_fname) msg = 'Creating imagerepo entry: {} -> {}' print(msg.format(unique_id, uri)) - lock = filelock.FileLock(repo_fname) + lock = filelock.FileLock(os.path.join(_RESULT_PATH, + 'imagerepo.lock')) # The imagerepo.json file is a critical resource, so ensure # thread safe read/write behaviour via platform independent # file locking. @@ -781,7 +782,7 @@ def _hex_to_hash(hexstr, hash_size=_HASH_SIZE): # Calculate the hamming distance vector for the result hash. distances = [e - phash for e in expected] - if np.all([hd > tol for hd in distances]): + if np.all([hd > _HAMMING_DISTANCE for hd in distances]): if dev_mode: _create_missing() else: @@ -802,15 +803,6 @@ def _hex_to_hash(hexstr, hash_size=_HASH_SIZE): finally: plt.close() - def check_graphic(self): - """ - Checks that the image hash for the current matplotlib figure matches - the expected image hash for the current test. - - """ - fname = os.path.join(_RESULT_PATH, 'imagerepo.lock') - self._assert_graphic() - def _remove_testcase_patches(self): """Helper to remove per-testcase patches installed by :meth:`patch`.""" # Remove all patches made, ignoring errors.