summaryrefslogtreecommitdiff
path: root/tests/unit/config/test_configcommands.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-10-07 17:10:50 +0200
committerFlorian Bruhin <me@the-compiler.org>2018-10-07 17:11:56 +0200
commit927c2ff94ad3ef91e638dc841bb884253792fc2f (patch)
tree504464ae20e343e452382f911d4718ce1809d7d2 /tests/unit/config/test_configcommands.py
parent7cea4e32627e66d8476939095a2a50928b36085d (diff)
downloadqutebrowser-927c2ff94ad3ef91e638dc841bb884253792fc2f.tar.gz
qutebrowser-927c2ff94ad3ef91e638dc841bb884253792fc2f.zip
Improve :config-add-(list|dict) tests
Diffstat (limited to 'tests/unit/config/test_configcommands.py')
-rw-r--r--tests/unit/config/test_configcommands.py44
1 files changed, 10 insertions, 34 deletions
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index 3ed1f4620..249357010 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -300,28 +300,17 @@ class TestAdd:
assert yaml_value(name)[-1] == value
def test_add_list_non_list(self, commands):
- name = 'history_gap_interval'
- value = 'value'
with pytest.raises(
cmdexc.CommandError,
match=":config-add-list can only be used for lists"):
- commands.config_add_list(name, value)
+ commands.config_add_list('history_gap_interval', 'value')
- def test_add_list_empty_value(self, commands):
- name = 'content.host_blocking.whitelist'
- value = ''
- with pytest.raises(
- cmdexc.CommandError,
- match="Invalid value '{}' - may not be empty!".format(value)):
- commands.config_add_list(name, value)
-
- def test_add_list_none_value(self, commands):
- name = 'content.host_blocking.whitelist'
- value = None
+ @pytest.mark.parametrize('value', ['', None, 42])
+ def test_add_list_invalid_values(self, commands, value):
with pytest.raises(
cmdexc.CommandError,
- match="Invalid value 'None' - may not be null!"):
- commands.config_add_list(name, value)
+ match="Invalid value '{}'".format(value)):
+ commands.config_add_list('content.host_blocking.whitelist', value)
@pytest.mark.parametrize('value', ['test1', 'test2'])
@pytest.mark.parametrize('temp', [True, False])
@@ -354,29 +343,16 @@ class TestAdd:
commands.config_add_dict(name, key, value, replace=False)
def test_add_dict_non_dict(self, commands):
- name = 'history_gap_interval'
- key = 'value'
- value = 'value'
with pytest.raises(
cmdexc.CommandError,
match=":config-add-dict can only be used for dicts"):
- commands.config_add_dict(name, key, value)
+ commands.config_add_dict('history_gap_interval', 'key', 'value')
- def test_add_dict_empty_value(self, commands):
- name = 'aliases'
- key = 'missingkey'
- value = ''
- with pytest.raises(cmdexc.CommandError,
- match="Invalid value '' - may not be empty!"):
- commands.config_add_dict(name, key, value)
-
- def test_add_dict_none_value(self, commands):
- name = 'aliases'
- key = 'missingkey'
- value = None
+ @pytest.mark.parametrize('value', ['', None, 42])
+ def test_add_dict_invalid_values(self, commands, value):
with pytest.raises(cmdexc.CommandError,
- match="Invalid value 'None' - may not be null!"):
- commands.config_add_dict(name, key, value)
+ match="Invalid value '{}'".format(value)):
+ commands.config_add_dict('aliases', 'missingkey', value)
class TestUnsetAndClear: