@@ -68,6 +68,9 @@ def iris(self):
6868 self ._iris = openml .datasets .get_dataset (61 , download_data = False )
6969 return self ._iris
7070
71+ def _get_cache_filename (self , id ):
72+ return self .http_client .cache_path_from_url (f"data/{ id } " )
73+
7174 def test_repr (self ):
7275 # create a bare-bones dataset as would be returned by
7376 # create_dataset
@@ -236,16 +239,14 @@ def test_get_data_corrupt_pickle(self):
236239 assert xy .shape == (150 , 5 )
237240
238241 def test_lazy_loading_metadata (self ):
239- # Initial Setup
240- did_cache_dir = Path (self .http_client .cache_path_from_url ("data/2" )).parent
241-
242242 _compare_dataset = openml .datasets .get_dataset (
243243 2 ,
244244 download_data = False ,
245245 download_features_meta_data = True ,
246246 download_qualities = True ,
247247 )
248- change_time = os .stat (did_cache_dir ).st_mtime
248+ did_cache_file = self ._get_cache_filename (2 )
249+ change_time = os .stat (did_cache_file ).st_mtime
249250
250251 # Test with cache
251252 _dataset = openml .datasets .get_dataset (
@@ -254,12 +255,12 @@ def test_lazy_loading_metadata(self):
254255 download_features_meta_data = False ,
255256 download_qualities = False ,
256257 )
257- assert change_time == os .stat (did_cache_dir ).st_mtime
258+ assert change_time == os .stat (did_cache_file ).st_mtime
258259 assert _dataset .features == _compare_dataset .features
259260 assert _dataset .qualities == _compare_dataset .qualities
260261
261262 # -- Test without cache
262- shutil . rmtree ( did_cache_dir )
263+ did_cache_file . unlink ( )
263264
264265 _dataset = openml .datasets .get_dataset (
265266 2 ,
@@ -268,8 +269,8 @@ def test_lazy_loading_metadata(self):
268269 download_qualities = False ,
269270 )
270271
271- assert "body.xml" in os . listdir ( did_cache_dir )
272- assert change_time != os .stat (did_cache_dir ).st_mtime
272+ assert did_cache_file . exists ( )
273+ assert change_time != os .stat (did_cache_file ).st_mtime
273274 assert _dataset .features == _compare_dataset .features
274275 assert _dataset .qualities == _compare_dataset .qualities
275276
0 commit comments