diff options
Diffstat (limited to 'tests/unit/config/test_configcommands.py')
-rw-r--r-- | tests/unit/config/test_configcommands.py | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py index 6dd09cee3..d7031de94 100644 --- a/tests/unit/config/test_configcommands.py +++ b/tests/unit/config/test_configcommands.py @@ -319,12 +319,13 @@ class TestAdd: 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( - cmdutils.CommandError, - match="Invalid value '{}'".format(value)): - commands.config_list_add('content.blocking.whitelist', value) + def test_list_add_invalid_value(self, commands): + with pytest.raises(cmdutils.CommandError, match="Invalid value ''"): + commands.config_list_add('content.blocking.whitelist', '') + + # FIXME test value conversion for :list-add like in test_dict_add_value_type + # (once we have a List config option using a non-str type, or a way to + # dynamically add new option definitions). @pytest.mark.parametrize('value', ['test1', 'test2']) @pytest.mark.parametrize('temp', [True, False]) @@ -368,11 +369,18 @@ class TestAdd: 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(cmdutils.CommandError, - match="Invalid value '{}'".format(value)): - commands.config_dict_add('aliases', 'missingkey', value) + def test_dict_add_invalid_value(self, commands): + with pytest.raises(cmdutils.CommandError, match="Invalid value ''"): + commands.config_dict_add('aliases', 'missingkey', '') + + def test_dict_add_value_type(self, commands, config_stub): + commands.config_dict_add( + "content.javascript.log_message.levels", + "example", + "['error']", + ) + value = config_stub.val.content.javascript.log_message.levels["example"] + assert value == ['error'] class TestRemove: @@ -407,8 +415,12 @@ class TestRemove: def test_list_remove_no_value(self, commands): with pytest.raises( cmdutils.CommandError, - match="never is not in colors.completion.fg!"): - commands.config_list_remove('colors.completion.fg', 'never') + match="#133742 is not in colors.completion.fg!"): + commands.config_list_remove('colors.completion.fg', '#133742') + + # FIXME test value conversion for :list-remove like in test_dict_add_value_type + # (once we have a List config option using a non-str type, or a way to + # dynamically add new option definitions). @pytest.mark.parametrize('key', ['w', 'q']) @pytest.mark.parametrize('temp', [True, False]) |