Skip to content

Commit adf0026

Browse files
committed
Fix #13 - Regex checks fail in 2.7
1 parent 2ab2622 commit adf0026

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

msrest/serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Serializer(object):
191191
"maximum_ex": lambda x, y: x >= y,
192192
"min_items": lambda x, y: len(x) < y,
193193
"max_items": lambda x, y: len(x) > y,
194-
"pattern": lambda x, y: not re.match(y, x),
194+
"pattern": lambda x, y: not re.match(y, x, re.UNICODE),
195195
"unique": lambda x, y: len(x) != len(set(x)),
196196
"multiple": lambda x, y: x % y != 0
197197
}

test/unittest_serialization.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ def setUp(self):
158158
self.s = Serializer()
159159
return super(TestRuntimeSerialized, self).setUp()
160160

161+
def test_validate(self):
162+
# Assert not necessary, should not raise exception
163+
self.s.validate("simplestring", "StringForLog", pattern="^[a-z]+$")
164+
self.s.validate(u"UTF8ééééé", "StringForLog", pattern=r"^[\w]+$")
165+
161166
def test_obj_serialize_none(self):
162167
"""Test that serialize None in object is still None.
163168
"""

0 commit comments

Comments
 (0)