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