Fixed ErrorOutput when special children
This commit is contained in:
@@ -129,7 +129,7 @@ class ErrorOutput:
|
||||
return item, None, None
|
||||
|
||||
def __str__(self):
|
||||
self.compute()
|
||||
return f"ErrorOutput({self.output})"
|
||||
|
||||
def compute(self):
|
||||
# first render the path hierarchy
|
||||
@@ -156,28 +156,27 @@ class ErrorOutput:
|
||||
self.indent += " "
|
||||
element_index = 0
|
||||
for expected_child in expected_children:
|
||||
if hasattr(expected_child, "tag"):
|
||||
if element_index < len(self.element.children):
|
||||
if element_index >= len(self.element.children):
|
||||
# When there are fewer children than expected, we display a placeholder
|
||||
child_str = "! ** MISSING ** !"
|
||||
self._add_to_output(child_str)
|
||||
element_index += 1
|
||||
continue
|
||||
|
||||
# display the child
|
||||
element_child = self.element.children[element_index]
|
||||
child_str = self._str_element(element_child, expected_child, keep_open=False)
|
||||
self._add_to_output(child_str)
|
||||
|
||||
# manage errors in children
|
||||
# manage errors (only when the expected is a FT element
|
||||
if hasattr(expected_child, "tag"):
|
||||
child_error_str = self._detect_error(element_child, expected_child)
|
||||
if child_error_str:
|
||||
self._add_to_output(child_error_str)
|
||||
|
||||
# continue
|
||||
element_index += 1
|
||||
|
||||
else:
|
||||
# When there are fewer children than expected, we display a placeholder
|
||||
child_str = "! ** MISSING ** !"
|
||||
self._add_to_output(child_str)
|
||||
|
||||
else:
|
||||
if expected_child in self.element.children:
|
||||
self._add_to_output(expected_child)
|
||||
|
||||
self.indent = self.indent[:-2]
|
||||
self._add_to_output(")")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user