Skip to content

Commit

Permalink
Use general regex to cut zsh reset ANSI sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Apr 23, 2023
1 parent e637120 commit cec49af
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import contextlib
import os
import os.path
import re
import shutil
import subprocess
import sys
Expand All @@ -11,7 +12,7 @@
from tempfile import NamedTemporaryFile, TemporaryFile, mkdtemp

import pexpect
from pexpect.replwrap import REPLWrapper, PEXPECT_PROMPT, PEXPECT_CONTINUATION_PROMPT
from pexpect.replwrap import PEXPECT_CONTINUATION_PROMPT, PEXPECT_PROMPT, REPLWrapper

TEST_DIR = os.path.abspath(os.path.dirname(__file__))
BASE_DIR = os.path.dirname(TEST_DIR)
Expand Down Expand Up @@ -48,8 +49,8 @@ def run_command(self, command, **kwargs):
if "\n" not in res:
raise Exception("Expected to see a newline in command response")
echo_cmd, actual_res = res.split("\n", 1)
actual_res = actual_res.replace("\x1b[0m\x1b[23m\x1b[24m\x1b[J", "")
return actual_res
res_without_ansi_seqs = re.sub(r"\x1b\[0m.+\x1b\[J", "", actual_res)
return res_without_ansi_seqs
else:
return res

Expand Down

0 comments on commit cec49af

Please sign in to comment.