@@ -278,65 +278,64 @@ def test_equality_comparison(self):
278278 self .assertNotEqual (self .titanic , "Wrong_object" )
279279
280280
281- class OpenMLDatasetTestOnTestServer (TestBase ):
282- def setUp (self ):
283- super ().setUp ()
284- # longley, really small dataset
285- self .dataset = openml .datasets .get_dataset (125 , download_data = False )
286-
287- def test_tagging (self ):
288- # tags can be at most 64 alphanumeric (+ underscore) chars
289- unique_indicator = str (time ()).replace ("." , "" )
290- tag = f"test_tag_OpenMLDatasetTestOnTestServer_{ unique_indicator } "
291- datasets = openml .datasets .list_datasets (tag = tag )
292- assert datasets .empty
293- self .dataset .push_tag (tag )
294- datasets = openml .datasets .list_datasets (tag = tag )
295- assert len (datasets ) == 1
296- assert 125 in datasets ["did" ]
297- self .dataset .remove_tag (tag )
298- datasets = openml .datasets .list_datasets (tag = tag )
299- assert datasets .empty
300-
301- def test_get_feature_with_ontology_data_id_11 (self ):
302- # test on car dataset, which has built-in ontology references
303- dataset = openml .datasets .get_dataset (11 )
304- assert len (dataset .features ) == 7
305- assert len (dataset .features [1 ].ontologies ) >= 2
306- assert len (dataset .features [2 ].ontologies ) >= 1
307- assert len (dataset .features [3 ].ontologies ) >= 1
308-
309- def test_add_remove_ontology_to_dataset (self ):
310- did = 1
311- feature_index = 1
312- ontology = "https://www.openml.org/unittest/" + str (time ())
313- openml .datasets .functions .data_feature_add_ontology (did , feature_index , ontology )
314- openml .datasets .functions .data_feature_remove_ontology (did , feature_index , ontology )
315-
316- def test_add_same_ontology_multiple_features (self ):
317- did = 1
318- ontology = "https://www.openml.org/unittest/" + str (time ())
319-
320- for i in range (3 ):
321- openml .datasets .functions .data_feature_add_ontology (did , i , ontology )
322-
323- def test_add_illegal_long_ontology (self ):
324- did = 1
325- ontology = "http://www.google.com/" + ("a" * 257 )
326- try :
327- openml .datasets .functions .data_feature_add_ontology (did , 1 , ontology )
328- assert False
329- except openml .exceptions .OpenMLServerException as e :
330- assert e .code == 1105
331-
332- def test_add_illegal_url_ontology (self ):
333- did = 1
334- ontology = "not_a_url" + str (time ())
335- try :
336- openml .datasets .functions .data_feature_add_ontology (did , 1 , ontology )
337- assert False
338- except openml .exceptions .OpenMLServerException as e :
339- assert e .code == 1106
281+ def test_tagging ():
282+ dataset = openml .datasets .get_dataset (125 , download_data = False )
283+
284+ # tags can be at most 64 alphanumeric (+ underscore) chars
285+ unique_indicator = str (time ()).replace ("." , "" )
286+ tag = f"test_tag_OpenMLDatasetTestOnTestServer_{ unique_indicator } "
287+ datasets = openml .datasets .list_datasets (tag = tag )
288+ assert datasets .empty
289+ dataset .push_tag (tag )
290+ datasets = openml .datasets .list_datasets (tag = tag )
291+ assert len (datasets ) == 1
292+ assert 125 in datasets ["did" ]
293+ dataset .remove_tag (tag )
294+ datasets = openml .datasets .list_datasets (tag = tag )
295+ assert datasets .empty
296+
297+ def test_get_feature_with_ontology_data_id_11 ():
298+ # test on car dataset, which has built-in ontology references
299+ dataset = openml .datasets .get_dataset (11 )
300+ assert len (dataset .features ) == 7
301+ assert len (dataset .features [1 ].ontologies ) >= 2
302+ assert len (dataset .features [2 ].ontologies ) >= 1
303+ assert len (dataset .features [3 ].ontologies ) >= 1
304+
305+ def test_add_remove_ontology_to_dataset ():
306+ did = 1
307+ feature_index = 1
308+ ontology = "https://www.openml.org/unittest/" + str (time ())
309+ openml .datasets .functions .data_feature_add_ontology (did , feature_index , ontology )
310+ openml .datasets .functions .data_feature_remove_ontology (did , feature_index , ontology )
311+
312+ def test_add_same_ontology_multiple_features ():
313+ did = 1
314+ ontology = "https://www.openml.org/unittest/" + str (time ())
315+
316+ for i in range (3 ):
317+ openml .datasets .functions .data_feature_add_ontology (did , i , ontology )
318+
319+
320+ def test_add_illegal_long_ontology ():
321+ did = 1
322+ ontology = "http://www.google.com/" + ("a" * 257 )
323+ try :
324+ openml .datasets .functions .data_feature_add_ontology (did , 1 , ontology )
325+ assert False
326+ except openml .exceptions .OpenMLServerException as e :
327+ assert e .code == 1105
328+
329+
330+
331+ def test_add_illegal_url_ontology ():
332+ did = 1
333+ ontology = "not_a_url" + str (time ())
334+ try :
335+ openml .datasets .functions .data_feature_add_ontology (did , 1 , ontology )
336+ assert False
337+ except openml .exceptions .OpenMLServerException as e :
338+ assert e .code == 1106
340339
341340
342341@pytest .mark .production ()
0 commit comments