diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-04 17:34:18 -0500 |
|---|---|---|
| committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-04 17:34:18 -0500 |
| commit | ffc4da088ecd7bee4f1f3822c35d906b67f3d0f7 (patch) | |
| tree | 3fa0a3e29df683fd30100bf6f2ae072d6130f36e | |
| parent | 4cde4b267ed28fabf16017d82ceff5b3a8ad90de (diff) | |
| download | cmd2-git-ffc4da088ecd7bee4f1f3822c35d906b67f3d0f7.tar.gz | |
Added unit test of colorize() method
| -rw-r--r-- | tests/test_cmd2.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 452d37dc..a663c164 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -342,3 +342,15 @@ now: True run_cmd(base_app, 'load does_not_exist.txt') out, err = capsys.readouterr() assert str(err).startswith('Traceback (most recent call last):') + + +def test_base_colorize(base_app): + # If using base_app test fixture it won't get colorized because we replaced self.stdout + color_test = base_app.colorize('Test', 'red') + assert color_test == 'Test' + + # But if we create a fresh Cmd() instance, it will + fresh_app = cmd2.Cmd() + color_test = fresh_app.colorize('Test', 'red') + assert color_test == '\x1b[31mTest\x1b[39m' + |
