Fix printing object reference on StringType
<object>.pattern is the correct pattern string from which the object was compiled from. Change-Id: I35eeca17d6edcc1a210ed7b3de2856a678fdc180 Closes-Bug: #1340879
This commit is contained in:
parent
2e1863db6c
commit
5de10eabe1
@ -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