summaryrefslogtreecommitdiff
path: root/tests/test_parsing.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-24 00:51:40 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-24 00:51:40 -0500
commit3e69e10328370884fc1a55de6ba9bef7f7e01d73 (patch)
treedc7a46d902b1993aedb9284faf648ffd0c2c99d5 /tests/test_parsing.py
parentb9ac44f889c42631808a4149a81f2e271990b75b (diff)
downloadcmd2-git-3e69e10328370884fc1a55de6ba9bef7f7e01d73.tar.gz
Added a couple unit tests for self.inputParser.
One passes and the other fails and demonstrates the overall problem with the failing unit test for input redirection on some systems where a "-" ends up in the path name.
Diffstat (limited to 'tests/test_parsing.py')
-rw-r--r--tests/test_parsing.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index 7186a143..b6ae0a15 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -43,6 +43,12 @@ def parser():
c._init_parser()
return c.parser
+@fixture
+def input_parser():
+ c = cmd2.Cmd()
+ c._init_parser()
+ return c.inputParser
+
def test_remaining_args():
assert cmd2.remaining_args('-f bar bar cow', ['bar', 'cow']) == 'bar cow'
@@ -237,6 +243,22 @@ def test_parse_output_redirect(parser):
- command: {0}""".format(command, args, redirect, output)
assert parser.parseString('output into > afile.txt').dump() == expected
+def test_parse_input_redirect(input_parser):
+ input_from = "< afile.txt"
+ if new_pyparsing:
+ input_from = repr(input_from)
+ expected = """['', {0}]
+- inputFrom: {0}""".format(input_from)
+ assert input_parser.parseString('< afile.txt').dump() == expected
+
+def test_parse_input_redirect_with_dash_in_path(input_parser):
+ input_from = "< python-cmd2/afile.txt"
+ if new_pyparsing:
+ input_from = repr(input_from)
+ expected = """['', {0}]
+- inputFrom: {0}""".format(input_from)
+ assert input_parser.parseString('< python-cmd2/afile.txt').dump() == expected
+
def test_parse_pipe_and_redirect(parser):
command = "output"
args = "into"