Skip to content

Commit 2edd5d0

Browse files
committed
update test_lazy_loading_metadata
1 parent b6c4b91 commit 2edd5d0

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

tests/test_datasets/test_dataset.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os
55
import unittest.mock
6+
import shutil
67
from time import time
78

89
import numpy as np
@@ -233,6 +234,44 @@ def test_get_data_corrupt_pickle(self):
233234
assert isinstance(xy, pd.DataFrame)
234235
assert xy.shape == (150, 5)
235236

237+
def test_lazy_loading_metadata(self):
238+
# Initial Setup
239+
# /home/geetu/work/gcos/openml-python/openml/tests.test_datasets.test_dataset.OpenMLDatasetTest.test_lazy_loading_metadata/org/openml/www/datasets/2
240+
cache_dir = openml.config.get_cache_directory()
241+
242+
_compare_dataset = openml.datasets.get_dataset(
243+
2,
244+
download_data=False,
245+
download_features_meta_data=True,
246+
download_qualities=True,
247+
)
248+
change_time = os.stat(cache_dir).st_mtime
249+
250+
# Test with cache
251+
_dataset = openml.datasets.get_dataset(
252+
2,
253+
download_data=False,
254+
download_features_meta_data=False,
255+
download_qualities=False,
256+
)
257+
assert change_time == os.stat(cache_dir).st_mtime
258+
assert _dataset.features == _compare_dataset.features
259+
assert _dataset.qualities == _compare_dataset.qualities
260+
261+
# -- Test without cache
262+
shutil.rmtree(cache_dir)
263+
264+
_dataset = openml.datasets.get_dataset(
265+
2,
266+
download_data=False,
267+
download_features_meta_data=False,
268+
download_qualities=False,
269+
)
270+
271+
assert change_time != os.stat(cache_dir).st_mtime
272+
assert _dataset.features == _compare_dataset.features
273+
assert _dataset.qualities == _compare_dataset.qualities
274+
236275
def test_equality_comparison(self):
237276
self.assertEqual(self.iris, self.iris)
238277
self.assertNotEqual(self.iris, self.titanic)

0 commit comments

Comments
 (0)