def test_solution_3(self): # Create the Tree nodes n1 = solution_3.Node(1) n2 = solution_3.Node(2) n3 = solution_3.Node(3) n4 = solution_3.Node(4) n5 = solution_3.Node(5) n6 = solution_3.Node(6) n7 = solution_3.Node(7) n8 = solution_3.Node(8) n9 = solution_3.Node(9) # connect the nodes n2.parent = n1 n3.parent = n1 n4.parent = n2 n5.parent = n2 n6.parent = n3 n7.parent = n3 n8.parent = n4 n9.parent = n4 self.assertEqual(solution_3.lca(n6, n7), 3) self.assertEqual(solution_3.lca(n3, n7), 3) self.assertEqual(solution_3.lca(n2, n8), 2) self.assertEqual(solution_3.lca(n4, n5), 2) self.assertEqual(solution_3.lca(n7, n8), 1) self.assertEqual(solution_3.lca(n4, n6), 1) self.assertEqual(solution_3.lca(n4, n3), 1) self.assertEqual(solution_3.lca(n4, n1), 1) self.assertEqual(solution_3.lca(404, n1), None)
def test_node_6_and_node_7(self, capsys,tree): print(lca(tree, 6,7).value) sys.stderr.write("") captured=capsys.readouterr() assert captured.out == "3\n" assert captured.err == ""