diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-07-01 00:34:07 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-07-01 00:34:07 -0400 |
commit | 031f2626e63708e4a7334826167a97d56fa29fdb (patch) | |
tree | d2ae15a9f8427b785e86d99b529fd98d12e7188a /tests/test_ansi.py | |
parent | 0bcd2905177bfd62c51c9181926869c9ec2deb0d (diff) | |
download | cmd2-git-031f2626e63708e4a7334826167a97d56fa29fdb.tar.gz |
Modified async_alert_str to also get passed the number of terminal columns and added unit tests for it
Diffstat (limited to 'tests/test_ansi.py')
-rw-r--r-- | tests/test_ansi.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_ansi.py b/tests/test_ansi.py index 53c917d5..75e5ba35 100644 --- a/tests/test_ansi.py +++ b/tests/test_ansi.py @@ -99,3 +99,14 @@ def test_set_title_str(): BEL = '\007' title = HELLO_WORLD assert ansi.set_title_str(title) == OSC + '2;' + title + BEL + + +@pytest.mark.parametrize('cols, prompt, line, cursor, msg, expected', [ + (127, '(Cmd) ', 'help his', 12, ansi.style('Hello World!', fg='magenta'), '\x1b[2K\r\x1b[35mHello World!\x1b[39m'), + (127, '\n(Cmd) ', 'help ', 5, 'foo', '\x1b[2K\x1b[1A\x1b[2K\rfoo'), + (10, '(Cmd) ', 'help history of the american republic', 4, 'boo', '\x1b[3B\x1b[2K\x1b[1A\x1b[2K\x1b[1A\x1b[2K\x1b[1A\x1b[2K\x1b[1A\x1b[2K\rboo') +]) +def test_async_alert_str(cols, prompt, line, cursor, msg, expected): + alert_str = ansi.async_alert_str(terminal_columns=cols, prompt=prompt, line=line, cursor_offset=cursor, + alert_msg=msg) + assert alert_str == expected |