Add unittests for partial command parsing

This commit is contained in:
Florian Bruhin 2016-06-06 16:18:49 +02:00
parent c9d85d3a12
commit 520572321a
2 changed files with 11 additions and 0 deletions

View File

@ -146,6 +146,8 @@ def _generate_cmdline_tests():
# Command with no_cmd_split combined with an "invalid" command -> valid
for item in itertools.product(['bind x open'], separators, invalid):
yield TestCase(''.join(item), True)
# Partial command
yield TestCase('message-i', False)
@pytest.fixture(params=_generate_cmdline_tests(), ids=lambda e: e.cmd)

View File

@ -51,3 +51,12 @@ class TestCommandRunner:
assert result.count == 20
assert result.args == ['down']
assert result.cmdline == ['scroll', 'down']
def test_partial_parsing(self):
"""Test partial parsing with a runner where it's enabled.
The same with it being disabled is tested by test_parse_all.
"""
cr = runners.CommandRunner(0, partial_match=True)
result = cr.parse('message-i', aliases=False)
assert result.cmd.name == 'message-info'