diff options
| author | Ethan McCreadie <ethan.mccreadie@gopuff.com> | 2018-11-01 10:28:27 -0400 |
|---|---|---|
| committer | Ethan McCreadie <ethan.mccreadie@gopuff.com> | 2018-11-01 10:28:27 -0400 |
| commit | 607106cee4f4b59d2f875e532adbfb154cdd31c5 (patch) | |
| tree | 843f9723061d294f65d6fc53c207c3e98a4bea6d /tests/test_cmd2.py | |
| parent | eaf2918a8036e95a373cd9694317335dbc548cad (diff) | |
| download | cmd2-git-607106cee4f4b59d2f875e532adbfb154cdd31c5.tar.gz | |
Strip color codes when redirecting w/ ppaged()
Diffstat (limited to 'tests/test_cmd2.py')
| -rw-r--r-- | tests/test_cmd2.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 2dd08ff7..9bb85ffe 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -2109,6 +2109,24 @@ def test_ppaged(base_app): out = base_app.stdout.getvalue() assert out == msg + end +def test_ppaged_strips_color_when_redirecting(base_app): + msg = 'testing...' + end = '\n' + base_app.colors = cmd2.constants.COLORS_TERMINAL + base_app.redirecting = True + base_app.ppaged(Fore.RED + msg) + out = base_app.stdout.getvalue() + assert out == msg + end + +def test_ppaged_strips_color_when_redirecting_if_always(base_app): + msg = 'testing...' + end = '\n' + base_app.colors = cmd2.constants.COLORS_ALWAYS + base_app.redirecting = True + base_app.ppaged(Fore.RED + msg) + out = base_app.stdout.getvalue() + assert out == Fore.RED + msg + end + # we override cmd.parseline() so we always get consistent # command parsing by parent methods we don't override # don't need to test all the parsing logic here, because |
