def test_supports_args(config_stub, count, chains, count_expected, chains_expected): kp = basekeyparser.BaseKeyParser(0, supports_count=count, supports_chains=chains) assert kp._supports_count == count_expected assert kp._supports_chains == chains_expected
def setup(self, fake_keyconfig): """Set up mocks and read the test config.""" self.kp = basekeyparser.BaseKeyParser(0, supports_chains=True, supports_count=False) self.kp.execute = mock.Mock() self.kp.read_config('test')
def keyparser(key_config_stub): """Fixture providing a BaseKeyParser supporting count/chains.""" kp = basekeyparser.BaseKeyParser(0, supports_count=True, supports_chains=True) kp.execute = mock.Mock() yield kp
def setup(self, caplog, fake_keyconfig): self.kp = basekeyparser.BaseKeyParser(0) self.kp.execute = mock.Mock() with caplog.atLevel(logging.WARNING, log.keyboard.name): # Ignoring keychain 'ccc' in mode 'test' because keychains are not # supported there. self.kp.read_config('test')
def keyparser(): """Fixture providing a BaseKeyParser supporting count/chains.""" kp = basekeyparser.BaseKeyParser( 0, supports_count=True, supports_chains=True) kp.execute = mock.Mock() yield kp assert not kp._ambiguous_timer.isActive()
def setUp(self): objreg.register('key-config', fake_keyconfig) basekeyparser.usertypes.Timer = mock.Mock() self.kp = basekeyparser.BaseKeyParser(0, supports_chains=True, supports_count=True) self.kp.execute = mock.Mock() self.kp.read_config('test')
def setUp(self): """Set up mocks and read the test config.""" objreg.register('key-config', fake_keyconfig) self.timermock = mock.Mock() basekeyparser.usertypes.Timer = mock.Mock(return_value=self.timermock) self.kp = basekeyparser.BaseKeyParser(0, supports_chains=True, supports_count=False) self.kp.execute = mock.Mock() self.kp.read_config('test')
def test_split_count(config_stub, key_config_stub, input_key, supports_count, count, command): kp = basekeyparser.BaseKeyParser(0, supports_count=supports_count) kp._read_config('normal') for info in keyseq(input_key): kp.handle(info.to_event()) assert kp._count == count assert kp._sequence == keyseq(command)
def test_split_count(config_stub, key_config_stub, input_key, supports_count, count, command): kp = basekeyparser.BaseKeyParser(mode=usertypes.KeyMode.normal, win_id=0, supports_count=supports_count) for info in keyseq(input_key): kp.handle(info.to_event()) assert kp._count == count assert kp._sequence == keyseq(command)
def test_warn_on_keychains(self, caplog, warn_on_keychains): """Test _warn_on_keychains.""" kp = basekeyparser.BaseKeyParser( 0, supports_count=False, supports_chains=False) kp._warn_on_keychains = warn_on_keychains with caplog.at_level(logging.WARNING): kp._read_config('normal') assert bool(caplog.records) == warn_on_keychains
def setUp(self): patcher = mock.patch( 'qutebrowser.keyinput.basekeyparser.usertypes.Timer', autospec=True) patcher.start() objreg.register('key-config', fake_keyconfig) self.addCleanup(patcher.stop) self.kp = basekeyparser.BaseKeyParser(0) self.kp.execute = mock.Mock() self.kp.read_config('test')
def test_read_config_valid(self): """Test reading config.""" kp = basekeyparser.BaseKeyParser(0, supports_count=True, supports_chains=True) kp.read_config('test') assert 'ccc' in kp.bindings assert 'ctrl+a' in kp.special_bindings kp.read_config('test2') assert 'ccc' not in kp.bindings assert 'ctrl+a' not in kp.special_bindings assert 'foo' in kp.bindings assert 'ctrl+x' in kp.special_bindings
def test_read_config_valid(self): """Test reading config.""" kp = basekeyparser.BaseKeyParser(0, supports_count=True, supports_chains=True) kp.read_config('test') self.assertIn('ccc', kp.bindings) self.assertIn('ctrl+a', kp.special_bindings) kp.read_config('test2') self.assertNotIn('ccc', kp.bindings) self.assertNotIn('ctrl+a', kp.special_bindings) self.assertIn('foo', kp.bindings) self.assertIn('ctrl+x', kp.special_bindings)
def test_split_count(input_key, supports_count, expected): kp = basekeyparser.BaseKeyParser(0, supports_count=supports_count) kp._keystring = input_key assert kp._split_count() == expected
def _create_keyparser(mode): kp = basekeyparser.BaseKeyParser(mode=mode, win_id=0) kp.execute = mock.Mock() return kp
def setup(self, fake_keyconfig): self.kp = basekeyparser.BaseKeyParser(0, supports_chains=True, supports_count=True) self.kp.execute = mock.Mock() self.kp.read_config('test')
def test_splitcount(self, input_key, supports_count, expected): """Test split_count with only a count.""" kp = basekeyparser.BaseKeyParser(0, supports_count=supports_count) kp._keystring = input_key assert kp._split_count() == expected
def test_split_count(config_stub, input_key, supports_count, expected): kp = basekeyparser.BaseKeyParser(0, supports_count=supports_count) assert kp._split_count(input_key) == expected
def setUp(self): self.kp = basekeyparser.BaseKeyParser(0, supports_count=True)
def test_read_config_invalid(self): """Test reading config without setting it before.""" kp = basekeyparser.BaseKeyParser(0) with self.assertRaises(ValueError): kp.read_config()