def test_insert_illegal_type_raises_ValueError(self): # Arrange l = LinkedList(1) # Act + Assert with self.assertRaises(ValueError): l.insert('2')
def test_insert(self): # Arrange l = LinkedList(1) # Act l.insert(2) l.insert(3) # Assert self.assertEqual(1, l.item) self.assertEqual(2, l.next_l.item) self.assertEqual(3, l.next_l.next_l.item) self.assertEqual(None, l.next_l.next_l.next_l)
def _factory(l): _l = LinkedList(l[0]) for item in l[1:]: _l.insert(item) return _l