Validate configtypes.Key correctly
This commit is contained in:
parent
612387633d
commit
f40f4082ba
@ -1652,7 +1652,8 @@ class Key(BaseType):
|
||||
self._basic_py_validation(value, str)
|
||||
if not value:
|
||||
return None
|
||||
#if utils.is_special_key(value):
|
||||
# value = '<{}>'.format(utils.normalize_keystr(value[1:-1]))
|
||||
#return value
|
||||
return keyutils.KeySequence.parse(value)
|
||||
|
||||
try:
|
||||
return keyutils.KeySequence.parse(value)
|
||||
except keyutils.KeyParseError as e:
|
||||
raise configexc.ValidationError(value, str(e))
|
||||
|
@ -2064,6 +2064,10 @@ class TestKey:
|
||||
def test_to_py_valid(self, klass, val, expected):
|
||||
assert klass().to_py(val) == expected
|
||||
|
||||
def test_to_py_invalid(self, klass):
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().to_py('\U00010000')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('first, second, equal', [
|
||||
(re.compile('foo'), RegexEq('foo'), True),
|
||||
|
Loading…
Reference in New Issue
Block a user