Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions lib/iris/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down