Test key_to_string with all Qt.Key members.

This commit is contained in:
Florian Bruhin 2015-06-12 16:37:07 +02:00
parent 9b066ec50a
commit 8033931bae

View File

@ -410,6 +410,7 @@ class TestKeyToString:
(Qt.Key_Escape, 'Escape'),
(Qt.Key_A, 'A'),
(Qt.Key_degree, '°'),
(Qt.Key_Meta, 'Meta'),
])
def test_normal(self, key, expected):
"""Test a special key where QKeyEvent::toString works incorrectly."""
@ -422,6 +423,16 @@ class TestKeyToString:
# want to know if the mapping still behaves properly.
assert utils.key_to_string(Qt.Key_A) == 'A'
def test_all(self):
"""Make sure there's some sensible output for all keys."""
for name, value in sorted(vars(Qt).items()):
if not isinstance(value, Qt.Key):
continue
print(name)
string = utils.key_to_string(value)
assert string
string.encode('utf-8') # make sure it's encodable
class TestKeyEventToString: