Merge "Fix printing object reference on StringType"
This commit is contained in:
commit
a24f4c4449
@ -326,6 +326,15 @@ Value: 'v3'. Value should be one of: v., v.",
|
||||
v.validate('A')
|
||||
self.assertRaises(ValueError, v.validate, '_')
|
||||
|
||||
def test_validate_string_type_pattern_exception_message(self):
|
||||
regex = '^[a-zA-Z0-9]*$'
|
||||
v = types.StringType(pattern=regex)
|
||||
try:
|
||||
v.validate('_')
|
||||
self.assertFail()
|
||||
except ValueError as e:
|
||||
self.assertIn(regex, str(e))
|
||||
|
||||
def test_validate_ipv4_address_type(self):
|
||||
v = types.IPv4AddressType()
|
||||
v.validate('127.0.0.1')
|
||||
|
@ -218,7 +218,7 @@ class StringType(UserType):
|
||||
raise ValueError(error)
|
||||
|
||||
if self.pattern is not None and not self.pattern.search(value):
|
||||
error = 'Value should match the pattern %s' % self.pattern
|
||||
error = 'Value should match the pattern %s' % self.pattern.pattern
|
||||
raise ValueError(error)
|
||||
|
||||
return value
|
||||
|
Loading…
x
Reference in New Issue
Block a user