Handle empty command in CommandRunner.parse_all

Sicne we now call self._get_alias there, we also need to make sure it's
not an empty string before that.

Introduced in #1577. Fixes #1690.
This commit is contained in:
Florian Bruhin 2016-07-27 11:19:01 +02:00
parent be609d5779
commit 9ff006746f
2 changed files with 12 additions and 0 deletions

View File

@ -119,6 +119,9 @@ class CommandRunner(QObject):
Yields:
ParseResult tuples.
"""
if not text:
raise cmdexc.NoSuchCommandError("No command given")
if aliases:
text = self._get_alias(text, text)

View File

@ -53,6 +53,15 @@ class TestCommandRunner:
with pytest.raises(cmdexc.NoSuchCommandError):
list(cr.parse_all("alias_name"))
def test_parse_empty_with_alias(self):
"""An empty command should not crash.
See https://github.com/The-Compiler/qutebrowser/issues/1690
"""
cr = runners.CommandRunner(0)
with pytest.raises(cmdexc.NoSuchCommandError):
list(cr.parse_all(''))
def test_parse_with_count(self):
"""Test parsing of commands with a count."""
cr = runners.CommandRunner(0)