Remove unnecessary lines
This commit is contained in:
parent
1a227ae3a7
commit
05eb9bd08c
@ -92,26 +92,30 @@ class TestReadConfig:
|
|||||||
assert 'foo' in kp.bindings
|
assert 'foo' in kp.bindings
|
||||||
assert 'ctrl+x' in kp.special_bindings
|
assert 'ctrl+x' in kp.special_bindings
|
||||||
|
|
||||||
def test_on_keyconfig_changed(self):
|
def test_on_keyconfig_changed_mode_none(self):
|
||||||
"""Test the handling of changes in the config."""
|
"""Test the changes in config with _modename = None."""
|
||||||
kp = basekeyparser.BaseKeyParser(0, supports_count=False,
|
kp = basekeyparser.BaseKeyParser(0, supports_count=False,
|
||||||
supports_chains=False)
|
supports_chains=False)
|
||||||
kp.read_config = mock.Mock()
|
assert kp._modename is None
|
||||||
kp._modename = None
|
|
||||||
|
|
||||||
# No config set so self._modename is None
|
# No config set so self._modename is None
|
||||||
with pytest.raises(AssertionError) as excinfo:
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
kp.on_keyconfig_changed("normal")
|
kp.on_keyconfig_changed('normal')
|
||||||
assert "on_keyconfig_changed called but no section defined!" in str(
|
expected_text = "on_keyconfig_changed called but no section defined!"
|
||||||
excinfo.value)
|
assert str(excinfo.value) == expected_text
|
||||||
assert not kp.read_config.called
|
|
||||||
|
|
||||||
kp._modename = "normal"
|
def test_on_keyconfig_changed_mode_normal(self):
|
||||||
kp.on_keyconfig_changed("normal2")
|
"""Test the changes in config with _modename set."""
|
||||||
|
kp = basekeyparser.BaseKeyParser(0, supports_count=False,
|
||||||
|
supports_chains=False)
|
||||||
|
kp.read_config = mock.Mock()
|
||||||
|
|
||||||
|
kp._modename = 'normal'
|
||||||
|
kp.on_keyconfig_changed('normal2')
|
||||||
# Modenames are not equal so read_config() should not be called
|
# Modenames are not equal so read_config() should not be called
|
||||||
assert not kp.read_config.called
|
assert not kp.read_config.called
|
||||||
|
|
||||||
kp.on_keyconfig_changed("normal")
|
kp.on_keyconfig_changed('normal')
|
||||||
# Both modenames equal so read_config() should be called
|
# Both modenames equal so read_config() should be called
|
||||||
assert kp.read_config.called
|
assert kp.read_config.called
|
||||||
|
|
||||||
@ -158,10 +162,7 @@ class TestSpecialKeys:
|
|||||||
|
|
||||||
def test_no_binding(self, monkeypatch, fake_keyevent_factory):
|
def test_no_binding(self, monkeypatch, fake_keyevent_factory):
|
||||||
"""Test special key with no binding."""
|
"""Test special key with no binding."""
|
||||||
def none_return(binding):
|
monkeypatch.setattr(utils, 'keyevent_to_string', lambda binding: None)
|
||||||
return None
|
|
||||||
|
|
||||||
monkeypatch.setattr(utils, 'keyevent_to_string', none_return)
|
|
||||||
self.kp.handle(fake_keyevent_factory(Qt.Key_A, Qt.NoModifier))
|
self.kp.handle(fake_keyevent_factory(Qt.Key_A, Qt.NoModifier))
|
||||||
assert not self.kp.execute.called
|
assert not self.kp.execute.called
|
||||||
|
|
||||||
@ -243,12 +244,9 @@ class TestKeyChain:
|
|||||||
config_stub, monkeypatch):
|
config_stub, monkeypatch):
|
||||||
"""Test ambiguous keychain with timeout equal to 0."""
|
"""Test ambiguous keychain with timeout equal to 0."""
|
||||||
config_stub.data = CONFIG_NO_TIMEOUT
|
config_stub.data = CONFIG_NO_TIMEOUT
|
||||||
monkeypatch.setattr('qutebrowser.keyinput.basekeyparser.config',
|
|
||||||
config_stub)
|
|
||||||
self.kp.handle(fake_keyevent_factory(Qt.Key_A, text='a'))
|
self.kp.handle(fake_keyevent_factory(Qt.Key_A, text='a'))
|
||||||
assert self.kp.execute.called
|
assert self.kp.execute.called
|
||||||
timer = self.kp._ambiguous_timer
|
assert not self.kp._ambiguous_timer.isActive()
|
||||||
assert not timer.isActive()
|
|
||||||
|
|
||||||
def test_invalid_keychain(self, fake_keyevent_factory):
|
def test_invalid_keychain(self, fake_keyevent_factory):
|
||||||
"""Test invalid keychain."""
|
"""Test invalid keychain."""
|
||||||
@ -260,13 +258,11 @@ class TestKeyChain:
|
|||||||
monkeypatch, qtbot):
|
monkeypatch, qtbot):
|
||||||
"""Test delayec execute for ambiguous keychain."""
|
"""Test delayec execute for ambiguous keychain."""
|
||||||
config_stub.data = CONFIG
|
config_stub.data = CONFIG
|
||||||
monkeypatch.setattr('qutebrowser.keyinput.basekeyparser.config',
|
|
||||||
config_stub)
|
|
||||||
timer = self.kp._ambiguous_timer
|
|
||||||
# 'a' is an ambiguous result.
|
# 'a' is an ambiguous result.
|
||||||
self.kp.handle(fake_keyevent_factory(Qt.Key_A, text='a'))
|
self.kp.handle(fake_keyevent_factory(Qt.Key_A, text='a'))
|
||||||
assert not self.kp.execute.called
|
assert not self.kp.execute.called
|
||||||
assert timer.isActive()
|
assert self.kp._ambiguous_timer.isActive()
|
||||||
# We wait for the timeout to occur.
|
# We wait for the timeout to occur.
|
||||||
with qtbot.waitSignal(self.kp.keystring_updated, raising=True):
|
with qtbot.waitSignal(self.kp.keystring_updated, raising=True):
|
||||||
pass
|
pass
|
||||||
@ -329,3 +325,13 @@ class TestCount:
|
|||||||
self.kp.handle(fake_keyevent_factory(Qt.Key_A, text='c'))
|
self.kp.handle(fake_keyevent_factory(Qt.Key_A, text='c'))
|
||||||
self.kp.execute.assert_called_once_with('ccc', self.kp.Type.chain, 23)
|
self.kp.execute.assert_called_once_with('ccc', self.kp.Type.chain, 23)
|
||||||
assert self.kp._keystring == ''
|
assert self.kp._keystring == ''
|
||||||
|
|
||||||
|
|
||||||
|
def test_clear_keystring(qtbot):
|
||||||
|
"""Test that the keystring is cleared and the signal is emitted"""
|
||||||
|
kp = basekeyparser.BaseKeyParser(0)
|
||||||
|
kp._keystring = 'test'
|
||||||
|
kp.clear_keystring()
|
||||||
|
with qtbot.waitSignal(kp.keystring_updated):
|
||||||
|
pass
|
||||||
|
assert kp._keystring is ''
|
||||||
|
Loading…
Reference in New Issue
Block a user