def test_add_vocable(self, vocable_not_in_list): length_of_vocables_before = len(VocableManager.vocables) VocableManager.add_vocable(vocable_not_in_list) length_of_vocables_after = len(VocableManager.vocables) assert vocable_not_in_list in VocableManager.vocables, \ 'The vocable was not added.' assert length_of_vocables_before + 1 == length_of_vocables_after, \ 'Not exactly one vocable was added to the list of vocables.' number_of_vocables = len(VocableManager.vocables) random_indices = [] existing_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) existing_vocables.append(VocableManager.vocables[random_index]) for existing_vocable in existing_vocables: try: VocableManager.add_vocable(existing_vocable) assert False, \ 'could add existing vocable again' except DuplicateVocableException as dvexception: pass
def test_add_vocable(self, vocable_not_in_list): length_of_vocables_before = len(VocableManager.vocables) VocableManager.add_vocable(vocable_not_in_list) length_of_vocables_after = len(VocableManager.vocables) assert vocable_not_in_list in VocableManager.vocables, \ 'The vocable was not added.' assert length_of_vocables_before + 1 == length_of_vocables_after, \ 'Not exactly one vocable was added to the list of vocables.' number_of_vocables = len(VocableManager.vocables) random_indices = [] existing_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) existing_vocables.append(VocableManager.vocables[random_index]) for existing_vocable in existing_vocables: try: VocableManager.add_vocable(existing_vocable) assert False, \ 'could add existing vocable again' except DuplicateVocableException as dvexception: pass