diff --git a/gdb-port/tests/unit/ast.py b/gdb-port/tests/unit/ast.py index 802c1e46a3aa3d75055f4eb769aba737741062b9..d67d232a221db65fbede195a143ae3daefd75753 100644 --- a/gdb-port/tests/unit/ast.py +++ b/gdb-port/tests/unit/ast.py @@ -140,3 +140,24 @@ class ASTManagerSetTopNode(unittest.TestCase): #self.assertEquals(ast_manager.top_node, hpr_mock_object) self.assertEqual(ast_manager.parser, p) self.assertEqual(self.hpr_mock_object.mock_calls, [unittest.mock.call(0xdeadbeef)]) + +class ASTManagerPrintAST(unittest.TestCase): + def setUp(self): + self.hpr_patcher = unittest.mock.patch('__main__.HParseResult', autospec=True) + self.parser_patcher = unittest.mock.patch('__main__.Parser', autospec=True) + self.hpr_mock_object = self.hpr_patcher.start() + self.parser_mock_object = self.parser_patcher.start() + + def tearDown(self): + self.parser_patcher.stop() + self.hpr_patcher.stop() + + @unittest.mock.patch("builtins.print") + def test_print_ast(self, print_mock): + p = Parser('test_parser', 0xdeadbfff) + ast_manager = ASTManager() + ast_manager.set_top_node(0xdeadbeef, p) + + ast_manager.print_ast() + + self.assertEqual(print_mock.mock_calls, [unittest.mock.call(ast_manager.parser), unittest.mock.call(ast_manager.top_node)])