summaryrefslogtreecommitdiff
path: root/tests/unit/config/test_configcommands.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-11-29 14:09:06 +0100
committerFlorian Bruhin <me@the-compiler.org>2018-11-29 14:18:11 +0100
commitb7de287e7bf053072eab47551e593d948fa8ced7 (patch)
treecdfc159315deaaaa6d229625c126e76c739c1d7d /tests/unit/config/test_configcommands.py
parentf9858733c1ba7d4500ad8b20bef281341dc12f12 (diff)
downloadqutebrowser-b7de287e7bf053072eab47551e593d948fa8ced7.tar.gz
qutebrowser-b7de287e7bf053072eab47551e593d948fa8ced7.zip
Move CommandError to api.cmdutils
Diffstat (limited to 'tests/unit/config/test_configcommands.py')
-rw-r--r--tests/unit/config/test_configcommands.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index 47bcaaa74..001d55899 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -26,7 +26,7 @@ import pytest
from PyQt5.QtCore import QUrl
from qutebrowser.config import configcommands, configutils
-from qutebrowser.commands import cmdexc
+from qutebrowser.api import cmdutils
from qutebrowser.utils import usertypes, urlmatch
from qutebrowser.keyinput import keyutils
from qutebrowser.misc import objects
@@ -108,7 +108,7 @@ class TestSet:
monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit)
option = 'content.javascript.enabled'
- with pytest.raises(cmdexc.CommandError,
+ with pytest.raises(cmdutils.CommandError,
match=('Error while parsing http://: Pattern '
'without host')):
commands.set(0, option, 'false', pattern='http://')
@@ -118,7 +118,7 @@ class TestSet:
Should show an error as patterns are unsupported.
"""
- with pytest.raises(cmdexc.CommandError,
+ with pytest.raises(cmdutils.CommandError,
match='does not support URL patterns'):
commands.set(0, 'colors.statusbar.normal.bg', '#abcdef',
pattern='*://*')
@@ -165,7 +165,7 @@ class TestSet:
Should show an error.
"""
- with pytest.raises(cmdexc.CommandError, match="No option 'foo'"):
+ with pytest.raises(cmdutils.CommandError, match="No option 'foo'"):
commands.set(0, 'foo', 'bar')
def test_set_invalid_value(self, commands):
@@ -173,13 +173,13 @@ class TestSet:
Should show an error.
"""
- with pytest.raises(cmdexc.CommandError,
+ with pytest.raises(cmdutils.CommandError,
match="Invalid value 'blah' - must be a boolean!"):
commands.set(0, 'auto_save.session', 'blah')
def test_set_wrong_backend(self, commands, monkeypatch):
monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebEngine)
- with pytest.raises(cmdexc.CommandError,
+ with pytest.raises(cmdutils.CommandError,
match="The hints.find_implementation setting is "
"not available with the QtWebEngine backend!"):
commands.set(0, 'hints.find_implementation', 'javascript')
@@ -190,7 +190,7 @@ class TestSet:
Should show an error.
See https://github.com/qutebrowser/qutebrowser/issues/1109
"""
- with pytest.raises(cmdexc.CommandError, match="No option '?'"):
+ with pytest.raises(cmdutils.CommandError, match="No option '?'"):
commands.set(win_id=0, option='?')
def test_toggle(self, commands):
@@ -198,7 +198,7 @@ class TestSet:
Should show an nicer error.
"""
- with pytest.raises(cmdexc.CommandError,
+ with pytest.raises(cmdutils.CommandError,
match="Toggling values was moved to the "
":config-cycle command"):
commands.set(win_id=0, option='javascript.enabled!')
@@ -208,7 +208,7 @@ class TestSet:
Should show an error.
"""
- with pytest.raises(cmdexc.CommandError, match="No option 'foo'"):
+ with pytest.raises(cmdutils.CommandError, match="No option 'foo'"):
commands.set(win_id=0, option='foo?')
@@ -267,7 +267,7 @@ class TestCycle:
Should show an error.
"""
assert config_stub.val.url.auto_search == 'naive'
- with pytest.raises(cmdexc.CommandError, match="Need at least "
+ with pytest.raises(cmdutils.CommandError, match="Need at least "
"two values for non-boolean settings."):
commands.config_cycle(*args)
assert config_stub.val.url.auto_search == 'naive'
@@ -301,14 +301,14 @@ class TestAdd:
def test_list_add_non_list(self, commands):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match=":config-list-add can only be used for lists"):
commands.config_list_add('history_gap_interval', 'value')
@pytest.mark.parametrize('value', ['', None, 42])
def test_list_add_invalid_values(self, commands, value):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match="Invalid value '{}'".format(value)):
commands.config_list_add('content.host_blocking.whitelist', value)
@@ -337,20 +337,20 @@ class TestAdd:
assert str(config_stub.get(name)[key]) == value
else:
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match="w already exists in aliases - use --replace to "
"overwrite!"):
commands.config_dict_add(name, key, value, replace=False)
def test_dict_add_non_dict(self, commands):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match=":config-dict-add can only be used for dicts"):
commands.config_dict_add('history_gap_interval', 'key', 'value')
@pytest.mark.parametrize('value', ['', None, 42])
def test_dict_add_invalid_values(self, commands, value):
- with pytest.raises(cmdexc.CommandError,
+ with pytest.raises(cmdutils.CommandError,
match="Invalid value '{}'".format(value)):
commands.config_dict_add('aliases', 'missingkey', value)
@@ -373,14 +373,14 @@ class TestRemove:
def test_list_remove_non_list(self, commands):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match=":config-list-remove can only be used for lists"):
commands.config_list_remove('content.javascript.enabled',
'never')
def test_list_remove_no_value(self, commands):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match="never is not in colors.completion.fg!"):
commands.config_list_remove('colors.completion.fg', 'never')
@@ -398,14 +398,14 @@ class TestRemove:
def test_dict_remove_non_dict(self, commands):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match=":config-dict-remove can only be used for dicts"):
commands.config_dict_remove('content.javascript.enabled',
'never')
def test_dict_remove_no_value(self, commands):
with pytest.raises(
- cmdexc.CommandError,
+ cmdutils.CommandError,
match="never is not in aliases!"):
commands.config_dict_remove('aliases', 'never')
@@ -425,7 +425,7 @@ class TestUnsetAndClear:
assert yaml_value(name) == ('never' if temp else configutils.UNSET)
def test_unset_unknown_option(self, commands):
- with pytest.raises(cmdexc.CommandError, match="No option 'tabs'"):
+ with pytest.raises(cmdutils.CommandError, match="No option 'tabs'"):
commands.config_unset('tabs')
@pytest.mark.parametrize('save', [True, False])
@@ -472,7 +472,7 @@ class TestSource:
pyfile = config_tmpdir / 'config.py'
pyfile.write_text('c.foo = 42', encoding='utf-8')
- with pytest.raises(cmdexc.CommandError) as excinfo:
+ with pytest.raises(cmdutils.CommandError) as excinfo:
commands.config_source()
expected = ("Errors occurred while reading config.py:\n"
@@ -483,7 +483,7 @@ class TestSource:
pyfile = config_tmpdir / 'config.py'
pyfile.write_text('1/0', encoding='utf-8')
- with pytest.raises(cmdexc.CommandError) as excinfo:
+ with pytest.raises(cmdutils.CommandError) as excinfo:
commands.config_source()
expected = ("Errors occurred while reading config.py:\n"
@@ -582,7 +582,7 @@ class TestWritePy:
confpy = tmpdir / 'config.py'
confpy.ensure()
- with pytest.raises(cmdexc.CommandError) as excinfo:
+ with pytest.raises(cmdutils.CommandError) as excinfo:
commands.config_write_py(str(confpy))
expected = " already exists - use --force to overwrite!"
@@ -599,7 +599,7 @@ class TestWritePy:
def test_oserror(self, commands, tmpdir):
"""Test writing to a directory which does not exist."""
- with pytest.raises(cmdexc.CommandError):
+ with pytest.raises(cmdutils.CommandError):
commands.config_write_py(str(tmpdir / 'foo' / 'config.py'))
@@ -709,7 +709,7 @@ class TestBind:
elif command == 'unbind':
func = commands.unbind
- with pytest.raises(cmdexc.CommandError, match=expected):
+ with pytest.raises(cmdutils.CommandError, match=expected):
func(*args, **kwargs)
@pytest.mark.parametrize('key', ['a', 'b', '<Ctrl-X>'])