diff options
author | Eric Lin <anselor@gmail.com> | 2020-08-20 13:35:47 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2020-08-20 18:08:45 -0400 |
commit | c62293103e97fd36a4f344d5d6c4c59a2c5b3e59 (patch) | |
tree | 095f9a241a1ca5d523d0fd993704b682385d1a33 /tests | |
parent | 9a20e7ca66bdab4581409d1eac16c931db08d6b6 (diff) | |
download | cmd2-git-c62293103e97fd36a4f344d5d6c4c59a2c5b3e59.tar.gz |
Updated documentation with more explicit discussions on testing
Added unit test to verify command name validation updates.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_parsing.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py index c2c242fe..62982ab5 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -836,7 +836,15 @@ def test_statement_is_immutable(): statement.raw = 'baz' -def test_is_valid_command_invalid(parser): +def test_is_valid_command_invalid(mocker, parser): + # Non-string command + valid, errmsg = parser.is_valid_command(5) + assert not valid and 'must be a string' in errmsg + + mock = mocker.MagicMock() + valid, errmsg = parser.is_valid_command(mock) + assert not valid and 'must be a string' in errmsg + # Empty command valid, errmsg = parser.is_valid_command('') assert not valid and 'cannot be an empty string' in errmsg @@ -871,6 +879,11 @@ def test_is_valid_command_valid(parser): assert valid assert not errmsg + # Subcommands can start with shortcut + valid, errmsg = parser.is_valid_command('!subcmd', is_subcommand=True) + assert valid + assert not errmsg + def test_macro_normal_arg_pattern(): # This pattern matches digits surrounded by exactly 1 brace on a side and 1 or more braces on the opposite side |