File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1919from cmd2 import (
2020 COMMAND_NAME ,
2121 Cmd2Style ,
22+ Color ,
2223 RichPrintKwargs ,
2324 clipboard ,
2425 constants ,
2526 exceptions ,
2627 plugin ,
28+ stylize ,
2729 utils ,
2830)
2931from cmd2 import rich_utils as ru
@@ -1232,6 +1234,33 @@ def test_default_to_shell(base_app, monkeypatch) -> None:
12321234 assert m .called
12331235
12341236
1237+ @pytest .mark .skip ('TODO: Replace escapte prompt stuff with prompt-toolkit equivalents' )
1238+ def test_escaping_prompt () -> None :
1239+ # This prompt has nothing which needs to be escaped
1240+ _prompt = '(Cmd) '
1241+ # TODO(T or K): Replace below with prompt-toolkit equivalent # noqa: FIX002, TD003
1242+ # assert rl_escape_prompt(prompt) == prompt # noqa: ERA001
1243+
1244+ # This prompt has color which needs to be escaped
1245+ _prompt = stylize ('InColor' , style = Color .CYAN )
1246+
1247+ _escape_start = "\x01 "
1248+ _escape_end = "\x02 "
1249+
1250+ # TODO(T or K): Replace below with prompt-toolkit equivalent # noqa: FIX002, TD003
1251+ # escaped_prompt = rl_escape_prompt(prompt) # noqa: ERA001
1252+ # if sys.platform.startswith('win'):
1253+ # # PyReadline on Windows doesn't need to escape invisible characters
1254+ # assert escaped_prompt == prompt # noqa: ERA001
1255+ # else: # noqa: ERA001
1256+ # cyan = "\x1b[36m" # noqa: ERA001
1257+ # reset_all = "\x1b[0m" # noqa: ERA001
1258+ # assert escaped_prompt.startswith(escape_start + cyan + escape_end) # noqa: ERA001
1259+ # assert escaped_prompt.endswith(escape_start + reset_all + escape_end) # noqa: ERA001
1260+
1261+ # assert rl_unescape_prompt(escaped_prompt) == prompt # noqa: ERA001
1262+
1263+
12351264class HelpApp (cmd2 .Cmd ):
12361265 """Class for testing custom help_* methods which override docstring help."""
12371266
You can’t perform that action at this time.
0 commit comments