home · contact · privacy
In line drawing testing, don't ignore whitespace characters' attributes.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 6 Mar 2026 01:20:26 +0000 (02:20 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 6 Mar 2026 01:20:26 +0000 (02:20 +0100)
src/ircplom/testing.py

index bc9fe665cc3054cd7158e105a89149b53d13b691..92c8ea6bce9090ac3114757c86abca46a7d26f16 100644 (file)
@@ -103,25 +103,27 @@ class TestTerminal(QueueMixin, TerminalInterface):
         assert 0 <= y < self.size.y
         assert 0 <= x < self.size.x
         text = _SCREENLINE_IGNORE_CHAR * x + text
+        idx_padding: Optional[int] = None
         if text.endswith(_SCREENLINE_PADDING_SUFFIX):
             text = text[:-len(_SCREENLINE_PADDING_SUFFIX)]
+            idx_padding = len(text)
             text += ' ' * (self.size.x - self.len_to_term(text))
         jumped_nones = 0
-        for idx, cell_expected in enumerate(
+        for idx_in_assertion, cell_expected in enumerate(
                 (tuple(attrs_str.split(_SEP_1)), c) for c in text):
-
-            cell_found = self._screen[y][idx+jumped_nones]
+            idx_with_jumped_nones = idx_in_assertion + jumped_nones
+            cell_found = self._screen[y][idx_with_jumped_nones]
             if cell_found is None:
                 jumped_nones += 1
                 continue
             if _SCREENLINE_IGNORE_CHAR == cell_expected[1]:
                 continue
-            info = ('AT_X', idx,
+            info = ('AT_X', idx_with_jumped_nones,
                     'CHAR EXPECTED', cell_expected, 'FOUND', cell_found,
                     'FULL LINE EXPECTED', text,
                     'FOUND', ''.join(t[1] for t in self._screen[y] if t))
             assert cell_expected[1] == cell_found[1], info
-            if cell_expected[1] != ' ':
+            if idx_padding is None or idx_in_assertion < idx_padding:
                 assert cell_expected[0] == cell_found[0], info