Skip to content

Commit e63fe10

Browse files
lbdreyermarqh
authored andcommitted
Fix filelock bug (#2225)
* Fix filelock bug.
1 parent 9cae764 commit e63fe10

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/iris/tests/__init__.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def _ensure_folder(self, path):
675675
logger.warning('Creating folder: %s', dir_path)
676676
os.makedirs(dir_path)
677677

678-
def _assert_graphic(self, tol=_HAMMING_DISTANCE):
678+
def check_graphic(self):
679679
"""
680680
Check the hash of the current matplotlib figure matches the expected
681681
image hash for the current graphic test.
@@ -734,7 +734,8 @@ def _create_missing():
734734
figure.savefig(hash_fname)
735735
msg = 'Creating imagerepo entry: {} -> {}'
736736
print(msg.format(unique_id, uri))
737-
lock = filelock.FileLock(repo_fname)
737+
lock = filelock.FileLock(os.path.join(_RESULT_PATH,
738+
'imagerepo.lock'))
738739
# The imagerepo.json file is a critical resource, so ensure
739740
# thread safe read/write behaviour via platform independent
740741
# file locking.
@@ -781,7 +782,7 @@ def _hex_to_hash(hexstr, hash_size=_HASH_SIZE):
781782
# Calculate the hamming distance vector for the result hash.
782783
distances = [e - phash for e in expected]
783784

784-
if np.all([hd > tol for hd in distances]):
785+
if np.all([hd > _HAMMING_DISTANCE for hd in distances]):
785786
if dev_mode:
786787
_create_missing()
787788
else:
@@ -802,15 +803,6 @@ def _hex_to_hash(hexstr, hash_size=_HASH_SIZE):
802803
finally:
803804
plt.close()
804805

805-
def check_graphic(self):
806-
"""
807-
Checks that the image hash for the current matplotlib figure matches
808-
the expected image hash for the current test.
809-
810-
"""
811-
fname = os.path.join(_RESULT_PATH, 'imagerepo.lock')
812-
self._assert_graphic()
813-
814806
def _remove_testcase_patches(self):
815807
"""Helper to remove per-testcase patches installed by :meth:`patch`."""
816808
# Remove all patches made, ignoring errors.

0 commit comments

Comments
 (0)