diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-02-04 22:18:56 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2020-02-04 22:18:56 -0500 |
commit | 14f456b0c3b70021fa650a596f81e0cfa7bd8949 (patch) | |
tree | 827e15626c891803c9fd3d667c1838f32bef8de4 /cmd2/utils.py | |
parent | 457123d3a1376a2ab713f0ff638313b0eacfcf3e (diff) | |
download | cmd2-git-14f456b0c3b70021fa650a596f81e0cfa7bd8949.tar.gz |
Fixed a bug in a very unusual case and added some unit tests
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index 2f2efefa..c200085a 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -64,10 +64,11 @@ def str_to_bool(val: str) -> bool: :return: boolean value expressed in the string :raises: ValueError if the string does not contain a value corresponding to a boolean value """ - if val.capitalize() == str(True): - return True - elif val.capitalize() == str(False): - return False + if isinstance(val, str): + if val.capitalize() == str(True): + return True + elif val.capitalize() == str(False): + return False raise ValueError("must be True or False") |