Make sure the config default values are mutable
While the old values meant the same thing, they weren't mutable, so the config couldn't modify them with a simple .append(). Fixes #3104
This commit is contained in:
parent
97a14c14b3
commit
27c46f20c0
@ -583,7 +583,7 @@ content.user_stylesheets:
|
||||
name: ListOrValue
|
||||
valtype: File
|
||||
none_ok: True
|
||||
default: null
|
||||
default: []
|
||||
desc: A list of user stylesheet filenames to use.
|
||||
|
||||
content.webgl:
|
||||
@ -1334,7 +1334,7 @@ url.start_pages:
|
||||
type:
|
||||
name: ListOrValue
|
||||
valtype: FuzzyUrl
|
||||
default: "https://start.duckduckgo.com"
|
||||
default: ["https://start.duckduckgo.com"]
|
||||
desc: The page(s) to open at the start.
|
||||
|
||||
url.yank_ignored_parameters:
|
||||
|
@ -30,16 +30,28 @@ from qutebrowser.utils import usertypes
|
||||
|
||||
|
||||
def test_init(config_stub):
|
||||
"""Test reading the default yaml file and validating the values."""
|
||||
"""Test reading the default yaml file."""
|
||||
# configdata.init() is called by config_stub
|
||||
config_stub.val.aliases = {}
|
||||
assert isinstance(configdata.DATA, dict)
|
||||
assert 'ignore_case' in configdata.DATA
|
||||
|
||||
|
||||
def test_data(config_stub):
|
||||
"""Test various properties of the default values."""
|
||||
for option in configdata.DATA.values():
|
||||
# Make sure to_py and to_str work
|
||||
option.typ.to_py(option.default)
|
||||
option.typ.to_str(option.default)
|
||||
|
||||
# https://github.com/qutebrowser/qutebrowser/issues/3104
|
||||
# For lists/dicts, don't use None as default
|
||||
if isinstance(option.typ, (configtypes.Dict, configtypes.List)):
|
||||
assert option.default is not None
|
||||
# For ListOrValue, use a list as default
|
||||
if isinstance(option.typ, configtypes.ListOrValue):
|
||||
assert isinstance(option.default, list)
|
||||
|
||||
|
||||
# https://github.com/qutebrowser/qutebrowser/issues/2777
|
||||
@pytest.mark.no_ci
|
||||
|
@ -461,6 +461,20 @@ class TestConfigPy:
|
||||
assert config.instance._values['aliases']['foo'] == 'message-info foo'
|
||||
assert config.instance._values['aliases']['bar'] == 'message-info bar'
|
||||
|
||||
@pytest.mark.parametrize('option, value', [
|
||||
('content.user_stylesheets', 'style.css'),
|
||||
('url.start_pages', 'https://www.python.org/'),
|
||||
])
|
||||
def test_appending(self, config_tmpdir, confpy, option, value):
|
||||
"""Test appending an item to some special list types.
|
||||
|
||||
See https://github.com/qutebrowser/qutebrowser/issues/3104
|
||||
"""
|
||||
(config_tmpdir / 'style.css').ensure()
|
||||
confpy.write('c.{}.append("{}")'.format(option, value))
|
||||
confpy.read()
|
||||
assert config.instance._values[option][-1] == value
|
||||
|
||||
def test_oserror(self, tmpdir, data_tmpdir, config_tmpdir):
|
||||
with pytest.raises(configexc.ConfigFileErrors) as excinfo:
|
||||
configfiles.read_config_py(str(tmpdir / 'foo'))
|
||||
|
Loading…
Reference in New Issue
Block a user