def add_node(self, value): node = LinkedNode(value) if self.__size == 0: self.__dummy.next_node = node self.__dummy.prev_node = node node.next_node = self.__dummy node.prev_node = self.__dummy else: node.next_node = self.__dummy.next_node node.prev_node = self.__dummy self.__dummy.next_node.prev_node = node self.__dummy.next_node = node self.__size += 1
def test_assignment(self): node1 = LinkedNode(4) node2 = LinkedNode("string") #Checking default values self.assertEqual(node1.prev_node, None) self.assertEqual(node1.next_node, None) #Checking Node Assignment try: node1.next_node = node2 exception = False except ValueError: exception = True self.assertFalse(exception) with self.assertRaises(ValueError): node2.next_node = "Bad Value"