MCPcopy Index your code
hub / github.com/python/cpython / clean_screen

Function clean_screen

Lib/test/test_pyrepl/support.py:51–66  ·  view source on GitHub ↗

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.

(reader: ReadlineAlikeReader)

Source from the content-addressed store, hash-verified

49
50
51def clean_screen(reader: ReadlineAlikeReader) -> list[str]:
52 """Cleans color and console characters out of a screen output.
53
54 This is useful for screen testing, it increases the test readability since
55 it strips out all the unreadable side of the screen.
56 """
57 output = []
58 for line in reader.screen:
59 line = unbracket(line, including_content=True)
60 line = ANSI_ESCAPE_SEQUENCE.sub("", line)
61 for prefix in (reader.ps1, reader.ps2, reader.ps3, reader.ps4):
62 if line.startswith(prefix):
63 line = line[len(prefix):]
64 break
65 output.append(line)
66 return output
67
68
69def prepare_reader(console: Console, **kwargs):

Callers 1

assert_screen_equalMethod · 0.85

Calls 4

unbracketFunction · 0.90
subMethod · 0.45
startswithMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…