def test_get_index_of_value_not_present(self): ''' When trying to get the index of a given value. 1. Pass the value to the method that is not in the list. 2. LookupError expected. ''' ll = LinkedList() some_value = "Jolis!" ll.append("A") ll.append("B") ll.append(some_value) ll.append("C") with self.assertRaises(LookupError): ll.get_index_of("Konnichiwa!")
def test_get_index_of(self): ''' When trying to get the index of a given value. 1. The value must be added to the list beforehand. 2. Pass the value to the method. 3. Must return the index of the element. ''' ll = LinkedList() some_value = "Jolis!" ll.append("A") ll.append("B") ll.append(some_value) ll.append("C") returnal = ll.get_index_of(some_value) self.assertEqual(returnal, 2) self.assertEqual(ll.get_at(returnal), some_value)