@@ -20,6 +20,7 @@ def hist():
2020 h = cmd2 .History ([HistoryItem ('first' ), HistoryItem ('second' ), HistoryItem ('third' ), HistoryItem ('fourth' )])
2121 return h
2222
23+ # Case-insensitive parser
2324@pytest .fixture
2425def parser ():
2526 c = cmd2 .Cmd ()
@@ -32,6 +33,33 @@ def parser():
3233 preparse = c .preparse , postparse = c .postparse , shortcuts = c .shortcuts )
3334 return c .parser_manager .main_parser
3435
36+ # Case-insensitive ParserManager
37+ @pytest .fixture
38+ def ci_pm ():
39+ c = cmd2 .Cmd ()
40+ c .multilineCommands = ['multiline' ]
41+ c .case_insensitive = True
42+ c .parser_manager = cmd2 .ParserManager (redirector = c .redirector , terminators = c .terminators , multilineCommands = c .multilineCommands ,
43+ legalChars = c .legalChars , commentGrammars = c .commentGrammars ,
44+ commentInProgress = c .commentInProgress , case_insensitive = c .case_insensitive ,
45+ blankLinesAllowed = c .blankLinesAllowed , prefixParser = c .prefixParser ,
46+ preparse = c .preparse , postparse = c .postparse , shortcuts = c .shortcuts )
47+ return c .parser_manager
48+
49+ # Case-sensitive ParserManager
50+ @pytest .fixture
51+ def cs_pm ():
52+ c = cmd2 .Cmd ()
53+ c .multilineCommands = ['multiline' ]
54+ c .case_insensitive = False
55+ c .parser_manager = cmd2 .ParserManager (redirector = c .redirector , terminators = c .terminators , multilineCommands = c .multilineCommands ,
56+ legalChars = c .legalChars , commentGrammars = c .commentGrammars ,
57+ commentInProgress = c .commentInProgress , case_insensitive = c .case_insensitive ,
58+ blankLinesAllowed = c .blankLinesAllowed , prefixParser = c .prefixParser ,
59+ preparse = c .preparse , postparse = c .postparse , shortcuts = c .shortcuts )
60+ return c .parser_manager
61+
62+
3563@pytest .fixture
3664def input_parser ():
3765 c = cmd2 .Cmd ()
@@ -190,6 +218,18 @@ def test_parse_output_redirect_with_dash_in_path(parser):
190218 assert results .output == '>'
191219 assert results .outputTo == 'python-cmd2/afile.txt'
192220
221+
222+ def test_case_insensitive_parsed_single_word (ci_pm ):
223+ line = 'HeLp'
224+ statement = ci_pm .parsed (line )
225+ assert statement .parsed .command == line .lower ()
226+
227+ def test_case_sensitive_parsed_single_word (cs_pm ):
228+ line = 'HeLp'
229+ statement = cs_pm .parsed (line )
230+ assert statement .parsed .command == line
231+
232+
193233def test_parse_input_redirect (input_parser ):
194234 line = '< afile.txt'
195235 results = input_parser .parseString (line )
0 commit comments