def test_remove_vocable_by_index(self): number_of_vocables = len(VocableManager.vocables) random_indices = [] selected_vocables = [] for index in range(100): # 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) assert CollectionsHelper.all_unique(random_indices), \ 'Trying to remove vocable of one and the same index twice during test.' deleted_vocables = [] random_indices.sort(reverse=True) for vocable_index in random_indices: deleted_vocables.append(VocableManager.vocables[vocable_index]) VocableManager.remove_vocable_by_index(vocable_index) assert deleted_vocables[-1] is not None, \ 'There is no handle on the deleted vocable anymore.' assert deleted_vocables[-1] not in VocableManager.vocables, \ 'Vocable was not deleted from vocables.' for vocable in deleted_vocables: print(vocable) for vocable in deleted_vocables: assert vocable not in VocableManager.vocables, \ 'Vocable was not deleted from vocables.'
def test_remove_vocable_by_index(self): number_of_vocables = len(VocableManager.vocables) random_indices = [] selected_vocables = [] for index in range(100): # 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) assert CollectionsHelper.all_unique(random_indices), \ 'Trying to remove vocable of one and the same index twice during test.' deleted_vocables = [] random_indices.sort(reverse=True) for vocable_index in random_indices: deleted_vocables.append(VocableManager.vocables[vocable_index]) VocableManager.remove_vocable_by_index(vocable_index) assert deleted_vocables[-1] is not None, \ 'There is no handle on the deleted vocable anymore.' assert deleted_vocables[-1] not in VocableManager.vocables, \ 'Vocable was not deleted from vocables.' for vocable in deleted_vocables: print(vocable) for vocable in deleted_vocables: assert vocable not in VocableManager.vocables, \ 'Vocable was not deleted from vocables.'