Move tests to test_runners.py

This commit is contained in:
Luca Benci 2017-10-10 22:51:40 +02:00
parent 5078080bb0
commit 787e3db3d5
2 changed files with 30 additions and 30 deletions

View File

@ -74,3 +74,32 @@ class TestCommandParser:
parser = runners.CommandParser(partial_match=True) parser = runners.CommandParser(partial_match=True)
result = parser.parse('message-i') result = parser.parse('message-i')
assert result.cmd.name == 'message-info' assert result.cmd.name == 'message-info'
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'

View File

@ -25,7 +25,7 @@ import pytest
from PyQt5.QtCore import QUrl, QProcess from PyQt5.QtCore import QUrl, QProcess
from qutebrowser.config import configcommands from qutebrowser.config import configcommands
from qutebrowser.commands import cmdexc, runners from qutebrowser.commands import cmdexc
from qutebrowser.utils import usertypes from qutebrowser.utils import usertypes
from qutebrowser.misc import objects from qutebrowser.misc import objects
@ -532,32 +532,3 @@ class TestBind:
""" """
with pytest.raises(cmdexc.CommandError, match=expected): with pytest.raises(cmdexc.CommandError, match=expected):
commands.unbind(key, mode=mode) 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'