From 4bbe2133a14df716b1dffe8ab7957ed67149b2cd Mon Sep 17 00:00:00 2001 From: Bernie Hackett Date: Tue, 22 Sep 2015 15:17:50 -0700 Subject: [PATCH] PYTHON-996 - Adjust regex tests for python 3.5 --- test/test_bson.py | 8 ++++---- test/test_json_util.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test_bson.py b/test/test_bson.py index 261ec0098..0ed11616b 100644 --- a/test/test_bson.py +++ b/test/test_bson.py @@ -731,14 +731,14 @@ class TestBSON(unittest.TestCase): self.assertEqual(doc1, BSON(doc1_bson).decode()) # Valid Python regex, with flags. - re2 = re.compile('.*', re.I | re.L | re.M | re.S | re.U | re.X) - bson_re2 = Regex('.*', re.I | re.L | re.M | re.S | re.U | re.X) + re2 = re.compile(u('.*'), re.I | re.M | re.S | re.U | re.X) + bson_re2 = Regex(u('.*'), re.I | re.M | re.S | re.U | re.X) doc2_with_re = {'r': re2} doc2_with_bson_re = {'r': bson_re2} doc2_bson = ( - b"\x12\x00\x00\x00" # document length - b"\x0br\x00.*\x00ilmsux\x00" # r: regex + b"\x11\x00\x00\x00" # document length + b"\x0br\x00.*\x00imsux\x00" # r: regex b"\x00") # document terminator self.assertEqual(doc2_bson, BSON.encode(doc2_with_re)) diff --git a/test/test_json_util.py b/test/test_json_util.py index 59a3559d7..a08f82645 100644 --- a/test/test_json_util.py +++ b/test/test_json_util.py @@ -113,10 +113,10 @@ class TestJsonUtil(unittest.TestCase): self.assertEqual("a*b", res.pattern) self.assertEqual(re.IGNORECASE, res.flags) - all_options = re.I|re.L|re.M|re.S|re.U|re.X - regex = re.compile("a*b", all_options) + unicode_options = re.I|re.M|re.S|re.U|re.X + regex = re.compile("a*b", unicode_options) res = self.round_tripped({"r": regex})["r"] - self.assertEqual(all_options, res.flags) + self.assertEqual(unicode_options, res.flags) # Some tools may not add $options if no flags are set. res = json_util.loads('{"r": {"$regex": "a*b"}}')['r']