Skip to content

Commit c65b1a1

Browse files
committed
utils.astring: Add ^c, ^!p, ^]104 and (\d+)h to skip chars
these are sometimes generated by kernel, ignore them. Signed-off-by: Lukáš Doktor <[email protected]> Signed-off-by: Sebastian Mitterle <[email protected]>
1 parent 506e44a commit c65b1a1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

aexpect/utils/astring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def strip_console_codes(output, custom_codes=None):
3737
output = f"\x1b[m{output}"
3838
console_codes = "^%[G@8]|^\\[[@A-HJ-MPXa-hl-nqrsu\\`]"
3939
console_codes += "|^\\[[\\d;]+[HJKgqnrm]|^#8|^\\([B0UK]|^\\)"
40-
console_codes += "|^\\[\\?2004[lh]"
40+
console_codes += "|^\\[\\?2004[lh]|^c|^\\[!p|^\\]\\d+|^\\[\\?\\d+h"
4141
if custom_codes is not None and custom_codes not in console_codes:
4242
console_codes += f"|{custom_codes}"
4343
while index < len(output):

tests/test_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def test_strip_console_codes(self):
3232
strip("\x1bskip-full-text"))
3333
self.assertEqual("ignores last",
3434
strip("ignores last\x1bbad"))
35+
self.assertEqual("skips c [!p and ]104",
36+
strip("skips\x1bc c \x1b[!p[!p and ]104\x1b]104"))
3537
self.assertRaisesRegex(ValueError, "only is not included", strip,
3638
"ignores\x1bonly\x1blast\x1bbad")
3739
self.assertRaisesRegex(ValueError, "invalid-prefix.*included", strip,

0 commit comments

Comments
 (0)