@@ -186,6 +186,8 @@ def skip_if_downloading_fails():
186186 if "hash check" in str (v_e ):
187187 raise unittest .SkipTest (f"Hash value error while downloading: { v_e } " ) from v_e
188188
189+ raise v_e
190+
189191
190192SAMPLE_TIFF = "https://huggingface.co/datasets/MONAI/testing_data/resolve/main/CMU-1.tiff"
191193SAMPLE_TIFF_HASH = "73a7e89bc15576587c3d68e55d9bf92f09690280166240b48ff4b48230b13bcd"
@@ -202,20 +204,15 @@ def test_download_url(self):
202204 ValueError: When the downloaded file's hash does not match.
203205 """
204206 with tempfile .TemporaryDirectory () as tempdir :
207+ model_path = os .path .join (tempdir , "model.tiff" )
208+
205209 with skip_if_downloading_fails ():
206210 download_url (
207- url = SAMPLE_TIFF ,
208- filepath = os .path .join (tempdir , "model.tiff" ),
209- hash_val = SAMPLE_TIFF_HASH ,
210- hash_type = SAMPLE_TIFF_HASH_TYPE ,
211+ url = SAMPLE_TIFF , filepath = model_path , hash_val = SAMPLE_TIFF_HASH , hash_type = SAMPLE_TIFF_HASH_TYPE
211212 )
212213 with self .assertRaises (ValueError ):
213- download_url (
214- url = SAMPLE_TIFF ,
215- filepath = os .path .join (tempdir , "model_bad.tiff" ),
216- hash_val = "0" * 64 ,
217- hash_type = SAMPLE_TIFF_HASH_TYPE ,
218- )
214+ # checking for wrong hash
215+ download_url (filepath = model_path , hash_val = "0" * 64 , hash_type = SAMPLE_TIFF_HASH_TYPE )
219216
220217
221218def test_pretrained_networks (network , input_param , device ):
0 commit comments