More test_config improvements
This commit is contained in:
parent
c214acd899
commit
d641652a92
@ -739,9 +739,7 @@ class Command(BaseType):
|
||||
# leading to an endless recursion.
|
||||
# To fix that, we turn off validating other commands (alias values)
|
||||
# while validating a command.
|
||||
# FIXME:conf Can't test this because we don't have a real config in
|
||||
# TestCommand
|
||||
if not Command.unvalidated: # pragma: no branch
|
||||
if not Command.unvalidated:
|
||||
Command.unvalidated = True
|
||||
try:
|
||||
from qutebrowser.commands import runners, cmdexc
|
||||
|
@ -613,6 +613,13 @@ class TestConfig:
|
||||
"""Test conf.get() with a QColor (where get/get_obj is different)."""
|
||||
assert conf.get('colors.completion.fg') == QColor('white')
|
||||
|
||||
@pytest.mark.parametrize('value', [{}, {'normal': {'a': 'nop'}}])
|
||||
def test_get_bindings(self, config_stub, conf, value):
|
||||
"""Test conf.get() with bindings which have missing keys."""
|
||||
config_stub.val.aliases = {}
|
||||
conf._values['bindings.commands'] = value
|
||||
assert conf.get('bindings.commands')['prompt'] == {}
|
||||
|
||||
def test_get_mutable(self, conf):
|
||||
"""Make sure we don't observe everything for mutations."""
|
||||
conf.get('content.headers.custom')
|
||||
@ -622,11 +629,12 @@ class TestConfig:
|
||||
assert conf.get_obj('colors.completion.fg') == 'white'
|
||||
|
||||
@pytest.mark.parametrize('option', ['content.headers.custom',
|
||||
'keyhint.blacklist'])
|
||||
'keyhint.blacklist',
|
||||
'bindings.commands'])
|
||||
@pytest.mark.parametrize('mutable', [True, False])
|
||||
@pytest.mark.parametrize('mutated', [True, False])
|
||||
def test_get_obj_mutable(self, conf, qtbot, caplog, option, mutable,
|
||||
mutated):
|
||||
def test_get_obj_mutable(self, conf, config_stub, qtbot, caplog,
|
||||
option, mutable, mutated):
|
||||
"""Make sure mutables are handled correctly.
|
||||
|
||||
When we get a mutable object from the config, some invariants should be
|
||||
@ -652,8 +660,7 @@ class TestConfig:
|
||||
if mutable:
|
||||
new = {'X-Answer': '42'}
|
||||
assert obj == new
|
||||
else:
|
||||
assert option == 'keyhint.blacklist'
|
||||
elif option == 'keyhint.blacklist':
|
||||
old = []
|
||||
new = []
|
||||
assert obj == old
|
||||
@ -662,6 +669,18 @@ class TestConfig:
|
||||
if mutable:
|
||||
new = ['foo']
|
||||
assert obj == new
|
||||
else:
|
||||
assert option == 'bindings.commands'
|
||||
config_stub.val.aliases = {}
|
||||
old = {}
|
||||
new = {}
|
||||
assert obj == old
|
||||
if mutated:
|
||||
obj['prompt'] = {}
|
||||
obj['prompt']['foobar'] = 'nop'
|
||||
if mutable:
|
||||
new = {'prompt': {'foobar': 'nop'}}
|
||||
assert obj == new
|
||||
|
||||
if mutable:
|
||||
assert conf._mutables == [(option, old, new)]
|
||||
|
Loading…
Reference in New Issue
Block a user