parent
47525f6a09
commit
4ef5db1bc4
@ -1654,6 +1654,13 @@ class Key(BaseType):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return keyutils.KeySequence.parse(value)
|
seq = keyutils.KeySequence.parse(value)
|
||||||
except keyutils.KeyParseError as e:
|
except keyutils.KeyParseError as e:
|
||||||
raise configexc.ValidationError(value, str(e))
|
raise configexc.ValidationError(value, str(e))
|
||||||
|
|
||||||
|
for info in seq:
|
||||||
|
if Qt.Key_1 <= info.key <= Qt.Key_9 and not info.modifiers:
|
||||||
|
raise configexc.ValidationError(
|
||||||
|
value, "Numbers are reserved for counts!")
|
||||||
|
|
||||||
|
return seq
|
||||||
|
@ -2061,13 +2061,16 @@ class TestKey:
|
|||||||
@pytest.mark.parametrize('val, expected', [
|
@pytest.mark.parametrize('val, expected', [
|
||||||
('gC', keyutils.KeySequence.parse('gC')),
|
('gC', keyutils.KeySequence.parse('gC')),
|
||||||
('<Control-x>', keyutils.KeySequence.parse('<ctrl+x>')),
|
('<Control-x>', keyutils.KeySequence.parse('<ctrl+x>')),
|
||||||
|
('<alt-1>', keyutils.KeySequence.parse('<alt+1>')),
|
||||||
|
('0', keyutils.KeySequence.parse('0')),
|
||||||
])
|
])
|
||||||
def test_to_py_valid(self, klass, val, expected):
|
def test_to_py_valid(self, klass, val, expected):
|
||||||
assert klass().to_py(val) == expected
|
assert klass().to_py(val) == expected
|
||||||
|
|
||||||
def test_to_py_invalid(self, klass):
|
@pytest.mark.parametrize('val', ['\U00010000', '<blub>', '1', 'a1'])
|
||||||
|
def test_to_py_invalid(self, klass, val):
|
||||||
with pytest.raises(configexc.ValidationError):
|
with pytest.raises(configexc.ValidationError):
|
||||||
klass().to_py('\U00010000')
|
klass().to_py(val)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('first, second, equal', [
|
@pytest.mark.parametrize('first, second, equal', [
|
||||||
|
Loading…
Reference in New Issue
Block a user