def test_remove_vocable_throws_exception(self, vocable_not_in_list): try: VocableManager.remove_vocable(vocable_not_in_list) assert False, 'could remove a not existing vocable' except UnknownVocableException as uvexception: pass try: VocableManager.remove_vocable(VocableManager.vocables[randint(0, len(VocableManager.vocables))]) except UnknownVocableException as uvexception: assert False, 'could not remove existing vocable'
def test_remove_vocable_throws_exception(self, vocable_not_in_list): try: VocableManager.remove_vocable(vocable_not_in_list) assert False, 'could remove a not existing vocable' except UnknownVocableException as uvexception: pass try: VocableManager.remove_vocable(VocableManager.vocables[randint( 0, len(VocableManager.vocables))]) except UnknownVocableException as uvexception: assert False, 'could not remove existing vocable'
def test_remove_vocable(self): # copied_vocables = [] # for index, vocable in enumerate(VocableManager.vocables): # current_vocable = VocableManager.vocables[index] # copied_vocables.append(current_vocable.clone()) # # assert len(copied_vocables) == len(VocableManager.vocables), \ # 'Not all vocables were copied.' # # for index, vocable in enumerate(copied_vocables): # if vocable not in VocableManager.vocables: # print(vocable) number_of_vocables = len(VocableManager.vocables) random_indices = [] selected_vocables = [] for index in range(1000): # get an index, which we've not yet selected random_index = randint(0, number_of_vocables-1) while random_index in random_indices: random_index = randint(0, number_of_vocables-1) random_indices.append(random_index) selected_vocables.append(VocableManager.vocables[random_index]) assert CollectionsHelper.all_unique(random_indices), \ 'Trying to remove vocable of one and the same index twice during test.' for selected_vocable in selected_vocables: VocableManager.remove_vocable(selected_vocable) # VocableManager.vocables.remove(selected_vocable) assert selected_vocable not in VocableManager.vocables, \ 'Vocable was not deleted from vocables. ' + \ str(VocableManager.test_call_counter) + \ ' calls for deletion.' + \ ' The vocable which was not deleted is ' + str(selected_vocable) print('Vocable deleted: ' + str(selected_vocable))
def test_remove_vocable(self): # copied_vocables = [] # for index, vocable in enumerate(VocableManager.vocables): # current_vocable = VocableManager.vocables[index] # copied_vocables.append(current_vocable.clone()) # # assert len(copied_vocables) == len(VocableManager.vocables), \ # 'Not all vocables were copied.' # # for index, vocable in enumerate(copied_vocables): # if vocable not in VocableManager.vocables: # print(vocable) number_of_vocables = len(VocableManager.vocables) random_indices = [] selected_vocables = [] for index in range(1000): # get an index, which we've not yet selected random_index = randint(0, number_of_vocables - 1) while random_index in random_indices: random_index = randint(0, number_of_vocables - 1) random_indices.append(random_index) selected_vocables.append(VocableManager.vocables[random_index]) assert CollectionsHelper.all_unique(random_indices), \ 'Trying to remove vocable of one and the same index twice during test.' for selected_vocable in selected_vocables: VocableManager.remove_vocable(selected_vocable) # VocableManager.vocables.remove(selected_vocable) assert selected_vocable not in VocableManager.vocables, \ 'Vocable was not deleted from vocables. ' + \ str(VocableManager.test_call_counter) + \ ' calls for deletion.' + \ ' The vocable which was not deleted is ' + str(selected_vocable) print('Vocable deleted: ' + str(selected_vocable))