ipalib.parameters: Require bytes for Bytes.pattern

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Petr Viktorin 2015-09-21 14:15:00 +02:00 committed by Tomas Babej
parent e0eff8b834
commit 614b490402
2 changed files with 4 additions and 2 deletions

View File

@ -1270,7 +1270,6 @@ class Data(Param):
('minlength', int, None), ('minlength', int, None),
('maxlength', int, None), ('maxlength', int, None),
('length', int, None), ('length', int, None),
('pattern', (six.string_types,), None),
('pattern_errmsg', (six.string_types,), None), ('pattern_errmsg', (six.string_types,), None),
) )
@ -1338,6 +1337,9 @@ class Bytes(Data):
type = bytes type = bytes
type_error = _('must be binary data') type_error = _('must be binary data')
kwargs = Data.kwargs + (
('pattern', (bytes,), None),
)
def __init__(self, name, *rules, **kw): def __init__(self, name, *rules, **kw):
if kw.get('pattern', None) is None: if kw.get('pattern', None) is None:
@ -1399,6 +1401,7 @@ class Str(Data):
""" """
kwargs = Data.kwargs + ( kwargs = Data.kwargs + (
('pattern', (six.string_types,), None),
('noextrawhitespace', bool, True), ('noextrawhitespace', bool, True),
) )

View File

@ -692,7 +692,6 @@ class test_Data(ClassChecker):
assert o.minlength is None assert o.minlength is None
assert o.maxlength is None assert o.maxlength is None
assert o.length is None assert o.length is None
assert o.pattern is None
# Test mixing length with minlength or maxlength: # Test mixing length with minlength or maxlength:
o = self.cls('my_data', length=5) o = self.cls('my_data', length=5)