Skip to content

Commit 92bc246

Browse files
committed
mock get
1 parent 713356e commit 92bc246

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

openml/datasets/functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,6 @@ def _topic_delete_dataset(data_id: int, topic: str) -> int:
871871
return openml._backend.dataset.delete_topic(data_id, topic)
872872

873873

874-
# TODO used by tests only
875874
def _get_dataset_description(did_cache_dir: Path, dataset_id: int) -> dict[str, Any]:
876875
"""Get the dataset description as xml dictionary.
877876

tests/test_datasets/test_dataset_functions.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,11 @@ def test_deletion_of_cache_dir(self):
522522
@mock.patch("openml.datasets.functions._get_dataset_description")
523523
@pytest.mark.test_server()
524524
def test_deletion_of_cache_dir_faulty_download(self, patch):
525-
patch.side_effect = Exception("Boom!")
526-
self.assertRaisesRegex(Exception, "Boom!", openml.datasets.get_dataset, dataset_id=1)
527-
datasets_cache_dir = os.path.join(openml.config.get_cache_directory(), "datasets")
528-
assert len(os.listdir(datasets_cache_dir)) == 0
525+
with mock.patch.object(openml._backend.dataset._http, "get") as patch_get:
526+
patch_get.side_effect = Exception("Boom!")
527+
self.assertRaisesRegex(Exception, "Boom!", openml.datasets.get_dataset, dataset_id=1)
528+
datasets_cache_dir = os.path.join(openml.config.get_cache_directory(), "datasets") #TODO cache path invalid
529+
assert len(os.listdir(datasets_cache_dir)) == 0
529530

530531
@pytest.mark.test_server()
531532
def test_publish_dataset(self):

0 commit comments

Comments
 (0)