77import warnings
88from os .path import isdir
99from os .path import join as pjoin
10+ from pathlib import Path
1011
1112import numpy as np
1213import pytest
4647)
4748
4849
49- def _hash_file_content (fname ):
50- hasher = hashlib .md5 ()
51- with open (fname , 'rb' ) as afile :
52- buf = afile .read ()
53- hasher .update (buf )
54- return hasher .hexdigest ()
55-
56-
5750@freesurfer_test
5851def test_geometry ():
5952 """Test IO of .surf"""
@@ -179,7 +172,6 @@ def test_annot():
179172 annots = ['aparc' , 'aparc.a2005s' ]
180173 for a in annots :
181174 annot_path = pjoin (data_path , 'label' , f'lh.{ a } .annot' )
182- hash_ = _hash_file_content (annot_path )
183175
184176 labels , ctab , names = read_annot (annot_path )
185177 assert labels .shape == (163842 ,)
@@ -190,9 +182,10 @@ def test_annot():
190182 labels_orig , _ , _ = read_annot (annot_path , orig_ids = True )
191183 np .testing .assert_array_equal (labels == - 1 , labels_orig == 0 )
192184 # Handle different version of fsaverage
193- if hash_ == 'bf0b488994657435cdddac5f107d21e8' :
185+ content_hash = hashlib .md5 (Path (annot_path ).read_bytes ()).hexdigest ()
186+ if content_hash == 'bf0b488994657435cdddac5f107d21e8' :
194187 assert np .sum (labels_orig == 0 ) == 13887
195- elif hash_ == 'd4f5b7cbc2ed363ac6fcf89e19353504' :
188+ elif content_hash == 'd4f5b7cbc2ed363ac6fcf89e19353504' :
196189 assert np .sum (labels_orig == 1639705 ) == 13327
197190 else :
198191 raise RuntimeError (
0 commit comments