summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pyrepl/support.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-07-13 13:56:56 (GMT)
committerGitHub <noreply@github.com>2024-07-13 13:56:56 (GMT)
commitde51ee0c2351124181e61613167a1c468380ceaa (patch)
treebb05e01d52d256eadd3c48b60b7015b81d4fd024 /Lib/test/test_pyrepl/support.py
parent5e8bb98419b01301a6b12b110526bc9a348eeb0b (diff)
downloadcpython-de51ee0c2351124181e61613167a1c468380ceaa.zip
cpython-de51ee0c2351124181e61613167a1c468380ceaa.tar.gz
cpython-de51ee0c2351124181e61613167a1c468380ceaa.tar.bz2
[3.13] gh-121499: Fix multi-line history rendering in the REPL (GH-121531) (#121679)
gh-121499: Fix multi-line history rendering in the REPL (GH-121531) (cherry picked from commit 4b9e10d0ea352592049c1f2a00318d7274143fa4) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/test/test_pyrepl/support.py')
-rw-r--r--Lib/test/test_pyrepl/support.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/support.py b/Lib/test/test_pyrepl/support.py
index 70e1228..58b1a92 100644
--- a/Lib/test/test_pyrepl/support.py
+++ b/Lib/test/test_pyrepl/support.py
@@ -38,6 +38,20 @@ def code_to_events(code: str):
yield Event(evt="key", data=c, raw=bytearray(c.encode("utf-8")))
+def clean_screen(screen: Iterable[str]):
+ """Cleans color and console characters out of a screen output.
+
+ This is useful for screen testing, it increases the test readability since
+ it strips out all the unreadable side of the screen.
+ """
+ output = []
+ for line in screen:
+ if line.startswith(">>>") or line.startswith("..."):
+ line = line[3:]
+ output.append(line)
+ return "\n".join(output).strip()
+
+
def prepare_reader(console: Console, **kwargs):
config = ReadlineConfig(readline_completer=kwargs.pop("readline_completer", None))
reader = ReadlineAlikeReader(console=console, config=config)