diff --git a/msrest/serialization.py b/msrest/serialization.py index ee81c21578..547623adcf 100644 --- a/msrest/serialization.py +++ b/msrest/serialization.py @@ -191,7 +191,7 @@ class Serializer(object): "maximum_ex": lambda x, y: x >= y, "min_items": lambda x, y: len(x) < y, "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x), + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), "unique": lambda x, y: len(x) != len(set(x)), "multiple": lambda x, y: x % y != 0 } diff --git a/test/unittest_serialization.py b/test/unittest_serialization.py index 166a375925..66be7bf825 100644 --- a/test/unittest_serialization.py +++ b/test/unittest_serialization.py @@ -158,6 +158,11 @@ def setUp(self): self.s = Serializer() return super(TestRuntimeSerialized, self).setUp() + def test_validate(self): + # Assert not necessary, should not raise exception + self.s.validate("simplestring", "StringForLog", pattern="^[a-z]+$") + self.s.validate(u"UTF8ééééé", "StringForLog", pattern=r"^[\w]+$") + def test_obj_serialize_none(self): """Test that serialize None in object is still None. """