Add (not fully working) tests for use_best_match

This commit is contained in:
Luca Benci 2017-10-10 22:02:25 +02:00
parent 0578349e29
commit 5078080bb0

View File

@ -25,7 +25,7 @@ import pytest
from PyQt5.QtCore import QUrl, QProcess
from qutebrowser.config import configcommands
from qutebrowser.commands import cmdexc
from qutebrowser.commands import cmdexc, runners
from qutebrowser.utils import usertypes
from qutebrowser.misc import objects
@ -532,3 +532,32 @@ class TestBind:
"""
with pytest.raises(cmdexc.CommandError, match=expected):
commands.unbind(key, mode=mode)
class TestCompletions:
"""Tests for completions.use_best_match."""
def test_dont_use_best_match(self, config_stub, monkeypatch):
"""Test multiple completion options with use_best_match set to false.
Should raise NoSuchCommandError
"""
config_stub.val.completion.use_best_match = False
monkeypatch.setattr('qutebrowser.config', config_stub)
parser = runners.CommandParser(partial_match=True)
with pytest.raises(cmdexc.NoSuchCommandError):
result = parser.parse('do')
def test_use_best_match(self, config_stub, monkeypatch):
"""Test multiple completion options with use_best_match set to true.
The resulting command should be the best match
"""
config_stub.val.completion.use_best_match = True
monkeypatch.setattr('qutebrowser.config', config_stub)
parser = runners.CommandParser(partial_match=True)
result = parser.parse('do')
assert result.cmd.name == 'download'