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