def test_lca(self): with self.assertRaises(TypeError): lca(None, None) with self.assertRaises(TypeError): lca(right3, None) with self.assertRaises(TypeError): lca(None, left13) with self.assertRaises(TypeError): lca(Node(value=None, parent=right3), None) with self.assertRaises(AttributeError): lca(right7, Node(value=None, parent=root_node)) with self.assertRaises(AttributeError): lca(Node(value=None, parent=root_node), left13) self.assertEqual(2, lca(left1, left1)) self.assertEqual(4, lca(left14, left4)) self.assertEqual(3, lca(right6, right7)) self.assertEqual(3, lca(right3, right7)) self.assertEqual(1, lca(root_node, left9))
def test_3_3(self): self.assertEqual(lca(node_6, node_1), node_1)
def test_3_4(self): self.assertEqual(lca(node_3, node_7), node_3)
def test_3_3(self): self.assertEqual(lca(node_8, node_4), node_4)
def test_3_2(self): self.assertEqual(lca(node_8, node_5), node_2)
def test_3_1(self): self.assertEqual(lca(node_9, node_5), node_2)