diff --git a/src/myfasthtml/test/matcher.py b/src/myfasthtml/test/matcher.py
index 1971dd8..bb7ee78 100644
--- a/src/myfasthtml/test/matcher.py
+++ b/src/myfasthtml/test/matcher.py
@@ -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,27 +156,26 @@ 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):
- # 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
- 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)
+ 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
- else:
- if expected_child in self.element.children:
- self._add_to_output(expected_child)
+ # 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 (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._add_to_output(")")