def test_Tree_CalculateValuesSubTree(tree, tree_sum, tree_avg, tree_median): t = Tree(tree) assert t.get_sum(full_tree=False, sub_tree=t.root.right) == tree_sum, "Incorrect sum" assert t.get_mean(full_tree=False, sub_tree=t.root.right) == tree_avg, "Incorrect average" assert t.get_median( full_tree=False, sub_tree=t.root.right) == tree_median, "Incorrect median"
def test_Tree_RaisesStatisticsErrorOnEmptyTree(a): t = Tree(a) assert t.get_sum(full_tree=True) == 0, "Incorrect sum" with pytest.raises(statistics.StatisticsError): t.get_median(full_tree=True) t.get_mean(full_tree=True)
def test_Tree_CalculateValuesFullTree(tree, tree_sum, tree_avg, tree_median): t = Tree(tree) assert t.get_sum(full_tree=True) == tree_sum, "Incorrect sum" assert t.get_mean(full_tree=True) == tree_avg, "Incorrect average" assert t.get_median(full_tree=True) == tree_median, "Incorrect median"