Skip to content

Commit b6c4b91

Browse files
committed
update test_list_all_few_results_available
1 parent 3778204 commit b6c4b91

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

tests/test_utils/test_utils.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import unittest.mock
55
import pytest
66
import openml
7+
import requests
78
from openml.testing import _check_dataset
89

910

@@ -43,11 +44,6 @@ def min_number_evaluations_on_test_server() -> int:
4344
return 8
4445

4546

46-
def _mocked_perform_api_call(call, request_method):
47-
url = openml.config.server + call
48-
return openml._api_calls._download_text_file(url)
49-
50-
5147
@pytest.mark.test_server()
5248
def test_list_all():
5349
openml.utils._list_all(listing_call=openml.tasks.functions._list_tasks)
@@ -115,13 +111,12 @@ def test_list_all_for_evaluations(min_number_evaluations_on_test_server):
115111
assert min_number_evaluations_on_test_server == len(evaluations)
116112

117113

118-
@unittest.mock.patch("openml._api_calls._perform_api_call", side_effect=_mocked_perform_api_call)
114+
@unittest.mock.patch.object(requests.Session, "request", autospec=True, wraps=requests.Session.request)
119115
@pytest.mark.test_server()
120-
def test_list_all_few_results_available(_perform_api_call):
116+
def test_list_all_few_results_available(mocked_request):
121117
datasets = openml.datasets.list_datasets(size=1000, data_name="iris", data_version=1)
122118
assert len(datasets) == 1, "only one iris dataset version 1 should be present"
123-
# TODO: _perform_api_call no more used
124-
#assert _perform_api_call.call_count == 1, "expect just one call to get one dataset"
119+
assert mocked_request.call_count == 1, "expect just one call to get one dataset"
125120

126121

127122
@unittest.skipIf(os.name == "nt", "https://github.com/openml/openml-python/issues/1033")

0 commit comments

Comments
 (0)