Commit | Line | Data |
---|---|---|
b39667cd MB |
1 | Fix regex so that it works with Python 3.6. |
2 | ||
3 | See <https://docs.python.org/3/library/re.html#re.LOCALE>. | |
4 | ||
5 | Copied from upstream bug report: | |
6 | https://bugs.launchpad.net/python-mox3/+bug/1665266 | |
7 | ||
8 | From 05064cdb6ea7a16450c6beae2b6f7c6074212a69 Mon Sep 17 00:00:00 2001 | |
9 | From: Zac Medico <zmedico@gentoo.org> | |
10 | Date: Thu, 16 Feb 2017 00:24:10 -0800 | |
11 | Subject: [PATCH] RegexTest: python3.6 compatibility | |
12 | ||
13 | These fixes are backward-compatible with older python versions: | |
14 | ||
15 | * raw strings fix invalid escape sequences | |
16 | * flags=8 fixes ValueError: cannot use LOCALE flag with a str pattern | |
17 | --- | |
18 | mox3/tests/test_mox.py | 6 +++--- | |
19 | 1 file changed, 3 insertions(+), 3 deletions(-) | |
20 | ||
21 | diff --git a/mox3/tests/test_mox.py b/mox3/tests/test_mox.py | |
22 | index 15ac565..3a1af17 100644 | |
23 | --- a/mox3/tests/test_mox.py | |
24 | +++ b/mox3/tests/test_mox.py | |
25 | @@ -312,12 +312,12 @@ class RegexTest(testtools.TestCase): | |
26 | def testReprWithoutFlags(self): | |
27 | """repr should return the regular expression pattern.""" | |
28 | self.assertTrue( | |
29 | - repr(mox.Regex(r"a\s+b")) == "<regular expression 'a\s+b'>") | |
30 | + repr(mox.Regex(r"a\s+b")) == r"<regular expression 'a\s+b'>") | |
31 | ||
32 | def testReprWithFlags(self): | |
33 | """repr should return the regular expression pattern and flags.""" | |
34 | - self.assertTrue(repr(mox.Regex(r"a\s+b", flags=4)) == | |
35 | - "<regular expression 'a\s+b', flags=4>") | |
36 | + self.assertTrue(repr(mox.Regex(r"a\s+b", flags=8)) == | |
37 | + r"<regular expression 'a\s+b', flags=8>") | |
38 | ||
39 | ||
40 | class IsTest(testtools.TestCase): | |
41 | -- | |
42 | 2.10.2 | |
43 |