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