Fix lint and tests
This commit is contained in:
parent
e26eaaddc2
commit
63e05e12ba
@ -17,14 +17,28 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import attr
|
||||
# pylint: disable=line-too-long
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
"""Data used by test_keyutils.py to test all keys."""
|
||||
|
||||
|
||||
import attr
|
||||
|
||||
|
||||
@attr.s
|
||||
class Key:
|
||||
|
||||
"""A key with expected values.
|
||||
|
||||
Attributes:
|
||||
attribute: The name of the Qt::Key attribute ('Foo' -> Qt.Key_Foo)
|
||||
name: The name returned by str(KeyInfo) with that key.
|
||||
text: The text returned by KeyInfo.text().
|
||||
uppertext: The text returned by KeyInfo.text() with shift.
|
||||
member: Filled by the test fixture, the numeric value.
|
||||
"""
|
||||
|
||||
attribute = attr.ib()
|
||||
name = attr.ib(None) # default: name == attribute
|
||||
text = attr.ib('')
|
||||
@ -289,7 +303,7 @@ KEYS = [
|
||||
|
||||
### Korean keyboard support
|
||||
###
|
||||
### In fact, many Korean users need only 2 keys, Key_Hangul and
|
||||
### In fact, many users from Korea need only 2 keys, Key_Hangul and
|
||||
### Key_Hangul_Hanja. But rest of the keys are good for future.
|
||||
|
||||
Key('Hangul'), # Hangul start/stop(toggle),
|
||||
|
@ -165,15 +165,10 @@ class TestSpecialKeys:
|
||||
Qt.Key_A, (Qt.ControlModifier | Qt.AltModifier)))
|
||||
assert not keyparser.execute.called
|
||||
|
||||
@pytest.mark.skip(reason='unneeded?')
|
||||
def test_keychain(self, fake_keyevent_factory, keyparser):
|
||||
keyparser.handle(fake_keyevent_factory(Qt.Key_B))
|
||||
keyparser.handle(fake_keyevent_factory(Qt.Key_A))
|
||||
assert not keyparser.execute.called
|
||||
|
||||
def test_no_binding(self, monkeypatch, fake_keyevent_factory, keyparser):
|
||||
def test_only_modifiers(self, monkeypatch, fake_keyevent_factory,
|
||||
keyparser):
|
||||
monkeypatch.setattr(keyutils.KeyInfo, '__str__', lambda _self: '')
|
||||
keyparser.handle(fake_keyevent_factory(Qt.Key_A, Qt.NoModifier))
|
||||
keyparser.handle(fake_keyevent_factory(Qt.Key_Shift, Qt.NoModifier))
|
||||
assert not keyparser.execute.called
|
||||
|
||||
def test_mapping(self, config_stub, fake_keyevent_factory, keyparser):
|
||||
|
@ -118,8 +118,8 @@ class TestKeyEventToString:
|
||||
('xyz', keyutils.KeySequence(Qt.Key_X, Qt.Key_Y, Qt.Key_Z)),
|
||||
('<Control-x><Meta-y>', keyutils.KeySequence(Qt.ControlModifier | Qt.Key_X,
|
||||
Qt.MetaModifier | Qt.Key_Y)),
|
||||
('<blub>', keyutils.KeyParseError),
|
||||
('\U00010000', keyutils.KeyParseError),
|
||||
('<blub>', keyutils.KeyParseError),
|
||||
('\U00010000', keyutils.KeyParseError),
|
||||
])
|
||||
def test_parse(keystr, expected):
|
||||
if expected is keyutils.KeyParseError:
|
||||
|
Loading…
Reference in New Issue
Block a user