diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-10-09 19:49:52 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-10-09 19:49:52 -0400 |
commit | 84f290bfdd82eb1c2eaf26b5936f7088b4911f2c (patch) | |
tree | c289c216807646567953191d35ebdc5c07198c24 /tests/test_completion.py | |
parent | 082fcc18eac962bfb511231b219f3737137dd757 (diff) | |
download | cmd2-git-84f290bfdd82eb1c2eaf26b5936f7088b4911f2c.tar.gz |
Increasing code coverage
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r-- | tests/test_completion.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py index d722e534..ed36eb01 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -716,6 +716,30 @@ def test_add_opening_quote_delimited_space_in_prefix(cmd2_app): os.path.commonprefix(cmd2_app.completion_matches) == expected_common_prefix and \ cmd2_app.display_matches == expected_display +def test_argparse_remainder_completion(cmd2_app): + # First test a positional with nargs=argparse.REMAINDER + text = '--h' + line = 'help command subcommand {}'.format(text) + endidx = len(line) + begidx = endidx - len(text) + + # --h should not complete into --help because we are in the argparse.REMAINDER sections + assert complete_tester(text, line, begidx, endidx, cmd2_app) is None + + # Now test a flag with nargs=argparse.REMAINDER + parser = argparse.ArgumentParser() + parser.add_argument('-f', nargs=argparse.REMAINDER) + + # Overwrite eof's parser for this test + cmd2.Cmd.do_eof.argparser = parser + + text = '--h' + line = 'eof -f {}'.format(text) + endidx = len(line) + begidx = endidx - len(text) + + # --h should not complete into --help because we are in the argparse.REMAINDER sections + assert complete_tester(text, line, begidx, endidx, cmd2_app) is None @pytest.fixture def sc_app(): |