summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-04-22 20:48:27 -0600
committerkotfu <kotfu@kotfu.net>2018-04-22 20:48:27 -0600
commit4f7d0f18509ab4f50c88e942e7ba33a7824b58ac (patch)
tree74f361f02754612482ed76d98400b265d0f18f63
parent7cec2eb3689fa6e8c2a36080841f2210dfa94697 (diff)
downloadcmd2-git-4f7d0f18509ab4f50c88e942e7ba33a7824b58ac.tar.gz
remove old pyparsing unit tests, they have all been duplicated in shlex
-rw-r--r--tests/test_parsing.py239
1 files changed, 0 insertions, 239 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index 2682ec68..5825e735 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -20,39 +20,6 @@ def hist():
h = cmd2.cmd2.History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')])
return h
-# Case-sensitive parser
-@pytest.fixture
-def parser():
- c = cmd2.Cmd()
- c.multilineCommands = ['multiline']
- c.parser_manager = cmd2.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, aliases=c.aliases,
- shortcuts=c.shortcuts)
- return c.parser_manager.main_parser
-
-# Case-sensitive ParserManager
-@pytest.fixture
-def cs_pm():
- c = cmd2.Cmd()
- c.multilineCommands = ['multiline']
- c.parser_manager = cmd2.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, aliases=c.aliases,
- shortcuts=c.shortcuts)
- return c.parser_manager
-
-
-@pytest.fixture
-def input_parser():
- c = cmd2.Cmd()
- return c.parser_manager.input_source_parser
-
-
def test_history_span(hist):
h = hist
assert h == ['first', 'second', 'third', 'fourth']
@@ -119,212 +86,6 @@ def test_cast_problems(capsys):
out, err = capsys.readouterr()
assert out == expected.format(current, new)
-
-def test_parse_empty_string(parser):
- assert parser.parseString('').dump() == '[]'
-
-def test_parse_only_comment(parser):
- assert parser.parseString('/* empty command */').dump() == '[]'
-
-def test_parse_single_word(parser):
- line = 'plainword'
- results = parser.parseString(line)
- assert results.command == line
-
-def test_parse_word_plus_terminator(parser):
- line = 'termbare;'
- results = parser.parseString(line)
- assert results.command == 'termbare'
- assert results.terminator == ';'
-
-def test_parse_suffix_after_terminator(parser):
- line = 'termbare; suffx'
- results = parser.parseString(line)
- assert results.command == 'termbare'
- assert results.terminator == ';'
- assert results.suffix == 'suffx'
-
-def test_parse_command_with_args(parser):
- line = 'command with args'
- results = parser.parseString(line)
- assert results.command == 'command'
- assert results.args == 'with args'
-
-def test_parse_command_with_args_terminator_and_suffix(parser):
- line = 'command with args and terminator; and suffix'
- results = parser.parseString(line)
- assert results.command == 'command'
- assert results.args == "with args and terminator"
- assert results.terminator == ';'
- assert results.suffix == 'and suffix'
-
-def test_parse_simple_piped(parser):
- line = 'simple | piped'
- results = parser.parseString(line)
- assert results.command == 'simple'
- assert results.pipeTo == " piped"
-
-def test_parse_double_pipe_is_not_a_pipe(parser):
- line = 'double-pipe || is not a pipe'
- results = parser.parseString(line)
- assert results.command == 'double-pipe'
- assert results.args == '|| is not a pipe'
- assert not 'pipeTo' in results
-
-def test_parse_complex_pipe(parser):
- line = 'command with args, terminator;sufx | piped'
- results = parser.parseString(line)
- assert results.command == 'command'
- assert results.args == "with args, terminator"
- assert results.terminator == ';'
- assert results.suffix == 'sufx'
- assert results.pipeTo == ' piped'
-
-def test_parse_output_redirect(parser):
- line = 'output into > afile.txt'
- results = parser.parseString(line)
- assert results.command == 'output'
- assert results.args == 'into'
- assert results.output == '>'
- assert results.outputTo == 'afile.txt'
-
-def test_parse_output_redirect_with_dash_in_path(parser):
- line = 'output into > python-cmd2/afile.txt'
- results = parser.parseString(line)
- assert results.command == 'output'
- assert results.args == 'into'
- assert results.output == '>'
- assert results.outputTo == 'python-cmd2/afile.txt'
-
-
-def test_case_sensitive_parsed_single_word(cs_pm):
- line = 'HeLp'
- statement = cs_pm.parsed(line)
- assert statement.parsed.command == line
-
-
-def test_parse_input_redirect(input_parser):
- line = '< afile.txt'
- results = input_parser.parseString(line)
- assert results.inputFrom == line
-
-def test_parse_input_redirect_with_dash_in_path(input_parser):
- line = "< python-cmd2/afile.txt"
- results = input_parser.parseString(line)
- assert results.inputFrom == line
-
-def test_parse_pipe_and_redirect(parser):
- line = 'output into;sufx | pipethrume plz > afile.txt'
- results = parser.parseString(line)
- assert results.command == 'output'
- assert results.args == 'into'
- assert results.terminator == ';'
- assert results.suffix == 'sufx'
- assert results.pipeTo == ' pipethrume plz'
- assert results.output == '>'
- assert results.outputTo == 'afile.txt'
-
-def test_parse_output_to_paste_buffer(parser):
- line = 'output to paste buffer >> '
- results = parser.parseString(line)
- assert results.command == 'output'
- assert results.args == 'to paste buffer'
- assert results.output == '>>'
-
-def test_parse_ignore_commented_redirectors(parser):
- line = 'ignore the /* commented | > */ stuff;'
- results = parser.parseString(line)
- assert results.command == 'ignore'
- assert results.args == 'the /* commented | > */ stuff'
- assert results.terminator == ';'
-
-def test_parse_has_redirect_inside_terminator(parser):
- """The terminator designates the end of the commmand/arguments portion. If a redirector
- occurs before a terminator, then it will be treated as part of the arguments and not as a redirector."""
- line = 'has > inside;'
- results = parser.parseString(line)
- assert results.command == 'has'
- assert results.args == '> inside'
- assert results.terminator == ';'
-
-def test_parse_what_if_quoted_strings_seem_to_start_comments(parser):
- line = 'what if "quoted strings /* seem to " start comments?'
- results = parser.parseString(line)
- assert results.command == 'what'
- assert results.args == 'if "quoted strings /* seem to " start comments?'
-
-def test_parse_unfinished_multiliine_command(parser):
- line = 'multiline has > inside an unfinished command'
- results = parser.parseString(line)
- assert results.multilineCommand == 'multiline'
- assert not 'args' in results
-
-def test_parse_multiline_command_ignores_redirectors_within_it(parser):
- line = 'multiline has > inside;'
- results = parser.parseString(line)
- assert results.multilineCommand == 'multiline'
- assert results.args == 'has > inside'
- assert results.terminator == ';'
-
-def test_parse_multiline_with_incomplete_comment(parser):
- """A terminator within a comment will be ignored and won't terminate a multiline command.
- Un-closed comments effectively comment out everything after the start."""
- line = 'multiline command /* with comment in progress;'
- results = parser.parseString(line)
- assert results.multilineCommand == 'multiline'
- assert not 'args' in results
-
-def test_parse_multiline_with_complete_comment(parser):
- line = 'multiline command /* with comment complete */ is done;'
- results = parser.parseString(line)
- assert results.multilineCommand == 'multiline'
- assert results.args == 'command /* with comment complete */ is done'
- assert results.terminator == ';'
-
-def test_parse_multiline_termninated_by_empty_line(parser):
- line = 'multiline command ends\n\n'
- results = parser.parseString(line)
- assert results.multilineCommand == 'multiline'
- assert results.args == 'command ends'
- assert len(results.terminator) == 2
- assert results.terminator[0] == '\n'
- assert results.terminator[1] == '\n'
-
-def test_parse_multiline_ignores_terminators_in_comments(parser):
- line = 'multiline command "with term; ends" now\n\n'
- results = parser.parseString(line)
- assert results.multilineCommand == 'multiline'
- assert results.args == 'command "with term; ends" now'
- assert len(results.terminator) == 2
- assert results.terminator[0] == '\n'
- assert results.terminator[1] == '\n'
-
-def test_parse_command_with_unicode_args(parser):
- line = 'drink café'
- results = parser.parseString(line)
- assert results.command == 'drink'
- assert results.args == 'café'
-
-def test_parse_unicode_command(parser):
- line = 'café au lait'
- results = parser.parseString(line)
- assert results.command == 'café'
- assert results.args == 'au lait'
-
-def test_parse_redirect_to_unicode_filename(parser):
- line = 'dir home > café'
- results = parser.parseString(line)
- assert results.command == 'dir'
- assert results.args == 'home'
- assert results.output == '>'
- assert results.outputTo == 'café'
-
-def test_parse_input_redirect_from_unicode_filename(input_parser):
- line = '< café'
- results = input_parser.parseString(line)
- assert results.inputFrom == line
-
-
def test_empty_statement_raises_exception():
app = cmd2.Cmd()
with pytest.raises(cmd2.cmd2.EmptyStatement):