def equal_to(a, b): """ Expected value comparator. Compares float values with math.isclose(), binary trees with equal_binary_trees(), and other types with == operator. """ if isinstance(a, float) or isinstance(b, float): return math.isclose(a, b) import binary_tree_node import binary_tree_with_parent_prototype import bst_node from test_framework.binary_tree_utils import equal_binary_trees if (isinstance(a, binary_tree_node.BinaryTreeNode) or isinstance(a, binary_tree_with_parent_prototype.BinaryTreeNode) or isinstance(a, bst_node.BstNode)) and ( isinstance(b, binary_tree_node.BinaryTreeNode) or isinstance( b, binary_tree_with_parent_prototype.BinaryTreeNode) or isinstance(b, bst_node.BstNode)): return equal_binary_trees(a, b) return a == b
def __eq__(self, other): return equal_binary_trees(self, other)