コード例 #1
0
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
コード例 #2
0
 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')
コード例 #3
0
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
コード例 #4
0
 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')
コード例 #5
0
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()
コード例 #6
0
 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')
コード例 #7
0
 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')
コード例 #8
0
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)
コード例 #9
0
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)
コード例 #10
0
    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
コード例 #11
0
 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')
コード例 #12
0
 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
コード例 #13
0
 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)
コード例 #14
0
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
コード例 #15
0
def _create_keyparser(mode):
    kp = basekeyparser.BaseKeyParser(mode=mode, win_id=0)
    kp.execute = mock.Mock()
    return kp
コード例 #16
0
 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')
コード例 #17
0
 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
コード例 #18
0
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
コード例 #19
0
 def setUp(self):
     self.kp = basekeyparser.BaseKeyParser(0, supports_count=True)
コード例 #20
0
 def test_read_config_invalid(self):
     """Test reading config without setting it before."""
     kp = basekeyparser.BaseKeyParser(0)
     with self.assertRaises(ValueError):
         kp.read_config()