diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-02 20:51:01 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-02 20:51:01 -0500 |
commit | b657b45dcca6687da43639c49e65ce4b16303d3d (patch) | |
tree | b4647b2bef6f9ba914d6711e5ddeebd82655fb7f /tests | |
parent | 40b52252a3108c8989afd6ca7e64ce9d4116cb4f (diff) | |
download | cmd2-git-b657b45dcca6687da43639c49e65ce4b16303d3d.tar.gz |
Removed support for case-insensitive command parsing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd2.py | 3 | ||||
-rw-r--r-- | tests/test_completion.py | 13 | ||||
-rw-r--r-- | tests/test_parsing.py | 36 |
3 files changed, 11 insertions, 41 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 6de86b2d..92f21757 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -88,7 +88,6 @@ def test_base_show_readonly(base_app): base_app.editor = 'vim' out = run_cmd(base_app, 'set -a') expected = normalize(SHOW_TXT + '\nRead only settings:' + """ - Commands are case-sensitive: {} Commands may be terminated with: {} Arguments at invocation allowed: {} Output redirection and pipes allowed: {} @@ -97,7 +96,7 @@ def test_base_show_readonly(base_app): Strip Quotes after splitting arguments: {} Argument type: {} -""".format(not base_app.case_insensitive, base_app.terminators, base_app.allow_cli_args, base_app.allow_redirection, +""".format(base_app.terminators, base_app.allow_cli_args, base_app.allow_redirection, "POSIX" if cmd2.POSIX_SHLEX else "non-POSIX", "True" if cmd2.STRIP_QUOTES_FOR_NON_POSIX and not cmd2.POSIX_SHLEX else "False", "List of argument strings" if cmd2.USE_ARG_LIST else "string of space-separated arguments")) diff --git a/tests/test_completion.py b/tests/test_completion.py index 5bdbf457..6f075c67 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -26,7 +26,6 @@ def cmd2_app(): @pytest.fixture def cs_app(): - cmd2.Cmd.case_insensitive = False c = cmd2.Cmd() return c @@ -136,21 +135,13 @@ def test_complete_bogus_command(cmd2_app): assert first_match is None -def test_cmd2_command_completion_is_case_insensitive_by_default(cmd2_app): +def test_cmd2_command_completion_is_case_sensitive(cmd2_app): text = 'HE' line = 'HE' endidx = len(line) begidx = endidx - len(text) # It is at end of line, so extra space is present - assert cmd2_app.completenames(text, line, begidx, endidx) == ['help '] - -def test_cmd2_case_sensitive_command_completion(cs_app): - text = 'HE' - line = 'HE' - endidx = len(line) - begidx = endidx - len(text) - # It is at end of line, so extra space is present - assert cs_app.completenames(text, line, begidx, endidx) == [] + assert cmd2_app.completenames(text, line, begidx, endidx) == [] def test_cmd2_command_completion_single_mid(cmd2_app): text = 'he' diff --git a/tests/test_parsing.py b/tests/test_parsing.py index c7abf07c..8ef9c5c0 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -20,41 +20,26 @@ def hist(): h = cmd2.History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')]) return h -# Case-insensitive parser +# Case-sensitive parser @pytest.fixture def parser(): c = cmd2.Cmd() c.multilineCommands = ['multiline'] - c.case_insensitive = True - c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, multilineCommands=c.multilineCommands, - legalChars=c.legalChars, commentGrammars=c.commentGrammars, - commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive, + c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, + multilineCommands=c.multilineCommands, legalChars=c.legalChars, + commentGrammars=c.commentGrammars, commentInProgress=c.commentInProgress, blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser, preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts) return c.parser_manager.main_parser -# Case-insensitive ParserManager -@pytest.fixture -def ci_pm(): - c = cmd2.Cmd() - c.multilineCommands = ['multiline'] - c.case_insensitive = True - c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, multilineCommands=c.multilineCommands, - legalChars=c.legalChars, commentGrammars=c.commentGrammars, - commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive, - blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser, - preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts) - return c.parser_manager - # Case-sensitive ParserManager @pytest.fixture def cs_pm(): c = cmd2.Cmd() c.multilineCommands = ['multiline'] - c.case_insensitive = False - c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, multilineCommands=c.multilineCommands, - legalChars=c.legalChars, commentGrammars=c.commentGrammars, - commentInProgress=c.commentInProgress, case_insensitive=c.case_insensitive, + c.parser_manager = cmd2.ParserManager(redirector=c.redirector, terminators=c.terminators, + multilineCommands=c.multilineCommands, legalChars=c.legalChars, + commentGrammars=c.commentGrammars, commentInProgress=c.commentInProgress, blankLinesAllowed=c.blankLinesAllowed, prefixParser=c.prefixParser, preparse=c.preparse, postparse=c.postparse, shortcuts=c.shortcuts) return c.parser_manager @@ -167,7 +152,7 @@ def test_parse_suffix_after_terminator(parser): assert results.suffix == 'suffx' def test_parse_command_with_args(parser): - line = 'COMmand with args' + line = 'command with args' results = parser.parseString(line) assert results.command == 'command' assert results.args == 'with args' @@ -219,11 +204,6 @@ def test_parse_output_redirect_with_dash_in_path(parser): assert results.outputTo == 'python-cmd2/afile.txt' -def test_case_insensitive_parsed_single_word(ci_pm): - line = 'HeLp' - statement = ci_pm.parsed(line) - assert statement.parsed.command == line.lower() - def test_case_sensitive_parsed_single_word(cs_pm): line = 'HeLp' statement = cs_pm.parsed(line) |