diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 12:48:13 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-06-29 12:48:13 -0400 |
commit | 1ca3ce9361ef0eb9c98ce8ec4cbd76e7b30140b2 (patch) | |
tree | edf9d440132a3b318dd8a778a246cb04bb98057c | |
parent | e73661cee4215a0ecf496316bbeac4663c722ed2 (diff) | |
download | cmd2-git-1ca3ce9361ef0eb9c98ce8ec4cbd76e7b30140b2.tar.gz |
Handling alternate cases of allow_ansi values
-rw-r--r-- | cmd2/cmd2.py | 2 | ||||
-rw-r--r-- | tests/test_cmd2.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 4abe4d07..31399620 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -564,7 +564,7 @@ class Cmd(cmd.Cmd): @allow_ansi.setter def allow_ansi(self, new_val: str) -> None: """Read-only property needed to support do_set when it sets allow_ansi""" - if new_val not in (ansi.ANSI_TERMINAL, ansi.ANSI_ALWAYS, ansi.ANSI_NEVER): + if new_val.lower() not in (ansi.ANSI_TERMINAL.lower(), ansi.ANSI_ALWAYS.lower(), ansi.ANSI_NEVER.lower()): self.perror('Invalid value: {} (valid values: {}, {}, {})'.format(new_val, ansi.ANSI_TERMINAL, ansi.ANSI_ALWAYS, ansi.ANSI_NEVER)) else: diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 47d8ce44..ab24384b 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -185,6 +185,9 @@ now: True (ansi.ANSI_NEVER, False), (ansi.ANSI_TERMINAL, False), (ansi.ANSI_ALWAYS, False), + ('neVeR', False), + ('TeRMInal', False), + ('AlWaYs', False), ('invalid', True), ]) def test_set_allow_ansi(base_app, new_val, is_valid): |