def test_inorder_single_node(self): bst = BinarySearchTree(data=5) stdout_org = sys.stdout stdout_mock = StdOutMock() try: sys.stdout = stdout_mock bst.inorder(bst.root) finally: sys.stdout = stdout_org self.assertEqual(str(stdout_mock), '5')
def test_inorder(self): bst = BinarySearchTree(data=5) bst.insert(3) bst.insert(7) bst.insert(1) bst.insert(2) bst.insert(9) bst.insert(6) stdout_org = sys.stdout stdout_mock = StdOutMock() try: sys.stdout = stdout_mock bst.inorder(bst.root) finally: sys.stdout = stdout_org self.assertEqual(str(stdout_mock), '1235679')