Fix tests on OS X, take two.
This commit is contained in:
parent
a9f5d45c34
commit
81ba49e79b
@ -326,19 +326,24 @@ def keyevent_to_string(e):
|
|||||||
A name of the key (combination) as a string or
|
A name of the key (combination) as a string or
|
||||||
None if only modifiers are pressed..
|
None if only modifiers are pressed..
|
||||||
"""
|
"""
|
||||||
modmask2str = collections.OrderedDict([
|
|
||||||
(Qt.ControlModifier, 'Ctrl'),
|
|
||||||
(Qt.AltModifier, 'Alt'),
|
|
||||||
(Qt.MetaModifier, 'Meta'),
|
|
||||||
(Qt.ShiftModifier, 'Shift'),
|
|
||||||
])
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
# Qt swaps Ctrl/Meta on OS X, so we switch it back here so the user can
|
# Qt swaps Ctrl/Meta on OS X, so we switch it back here so the user can
|
||||||
# use it in the config as expected. See:
|
# use it in the config as expected. See:
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/110
|
# https://github.com/The-Compiler/qutebrowser/issues/110
|
||||||
# http://doc.qt.io/qt-5.4/osx-issues.html#special-keys
|
# http://doc.qt.io/qt-5.4/osx-issues.html#special-keys
|
||||||
modmask2str[Qt.MetaModifier] = 'Ctrl'
|
modmask2str = collections.OrderedDict([
|
||||||
modmask2str[Qt.ControlModifier] = 'Meta'
|
(Qt.MetaModifier, 'Ctrl'),
|
||||||
|
(Qt.AltModifier, 'Alt'),
|
||||||
|
(Qt.ControlModifier, 'Meta'),
|
||||||
|
(Qt.ShiftModifier, 'Shift'),
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
modmask2str = collections.OrderedDict([
|
||||||
|
(Qt.ControlModifier, 'Ctrl'),
|
||||||
|
(Qt.AltModifier, 'Alt'),
|
||||||
|
(Qt.MetaModifier, 'Meta'),
|
||||||
|
(Qt.ShiftModifier, 'Shift'),
|
||||||
|
])
|
||||||
modifiers = (Qt.Key_Control, Qt.Key_Alt, Qt.Key_Shift, Qt.Key_Meta,
|
modifiers = (Qt.Key_Control, Qt.Key_Alt, Qt.Key_Shift, Qt.Key_Meta,
|
||||||
Qt.Key_AltGr, Qt.Key_Super_L, Qt.Key_Super_R,
|
Qt.Key_AltGr, Qt.Key_Super_L, Qt.Key_Super_R,
|
||||||
Qt.Key_Hyper_L, Qt.Key_Hyper_R, Qt.Key_Direction_L,
|
Qt.Key_Hyper_L, Qt.Key_Hyper_R, Qt.Key_Direction_L,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"""Tests for qutebrowser.utils.utils."""
|
"""Tests for qutebrowser.utils.utils."""
|
||||||
|
|
||||||
|
import sys
|
||||||
import enum
|
import enum
|
||||||
import datetime
|
import datetime
|
||||||
import os.path
|
import os.path
|
||||||
@ -312,10 +313,11 @@ class TestKeyEventToString:
|
|||||||
def test_key_and_modifier(self, fake_keyevent_factory):
|
def test_key_and_modifier(self, fake_keyevent_factory):
|
||||||
"""Test with key and modifier pressed."""
|
"""Test with key and modifier pressed."""
|
||||||
evt = fake_keyevent_factory(key=Qt.Key_A, modifiers=Qt.ControlModifier)
|
evt = fake_keyevent_factory(key=Qt.Key_A, modifiers=Qt.ControlModifier)
|
||||||
assert utils.keyevent_to_string(evt) == 'Ctrl+A'
|
expected = 'Meta+A' if sys.platform == 'darwin' else 'Ctrl+A'
|
||||||
|
assert utils.keyevent_to_string(evt) == expected
|
||||||
|
|
||||||
def test_key_and_modifiers(self, fake_keyevent_factory):
|
def test_key_and_modifiers(self, fake_keyevent_factory):
|
||||||
"""Test with key and multiple modifier pressed."""
|
"""Test with key and multiple modifiers pressed."""
|
||||||
evt = fake_keyevent_factory(
|
evt = fake_keyevent_factory(
|
||||||
key=Qt.Key_A, modifiers=(Qt.ControlModifier | Qt.AltModifier |
|
key=Qt.Key_A, modifiers=(Qt.ControlModifier | Qt.AltModifier |
|
||||||
Qt.MetaModifier | Qt.ShiftModifier))
|
Qt.MetaModifier | Qt.ShiftModifier))
|
||||||
|
Loading…
Reference in New Issue
Block a user