From 37e3e79faa902dcefa2e7acea5cb6b5e64175e23 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 19 Sep 2016 05:41:59 +0200 Subject: [PATCH] Check in the diff tests that the graph is valid. --- test/test_parser/test_diff_parser.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_parser/test_diff_parser.py b/test/test_parser/test_diff_parser.py index e76e15d6..2c9d6251 100644 --- a/test/test_parser/test_diff_parser.py +++ b/test/test_parser/test_diff_parser.py @@ -54,6 +54,20 @@ def _check_error_leaves_nodes(node): return False +def _assert_valid_graph(node): + """ + Checks if the parent/children relationship is correct. + """ + try: + children = node.children + except AttributeError: + return + + for child in children: + assert child.parent == node + _assert_valid_graph(child) + + class Differ(object): def initialize(self, source): debug.dbg('differ: initialize', color='YELLOW') @@ -71,7 +85,9 @@ class Differ(object): assert diff_parser._parser_count == parsers self.parser.module = new_module self.parser._parsed = new_module + assert expect_error_leafs == _check_error_leaves_nodes(new_module) + _assert_valid_graph(new_module) return new_module