summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-11 09:50:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-11 09:50:02 (GMT)
commitbd48d27944453ad83d3ce37b2c867fa0d59a1c15 (patch)
treef5585b5ce3995541ed6cce7bb4daef97f936be89 /Lib/test
parent352601ca00376aaf07d4399096f985d3d8ecb96f (diff)
downloadcpython-bd48d27944453ad83d3ce37b2c867fa0d59a1c15.zip
cpython-bd48d27944453ad83d3ce37b2c867fa0d59a1c15.tar.gz
cpython-bd48d27944453ad83d3ce37b2c867fa0d59a1c15.tar.bz2
Issue #22493: Inline flags now should be used only at the start of the
regular expression. Deprecation warning is emitted if uses them in the middle of the regular expression.
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/re_tests.py8
-rw-r--r--Lib/test/test_fnmatch.py16
-rw-r--r--Lib/test/test_pyclbr.py2
-rw-r--r--Lib/test/test_re.py3
4 files changed, 16 insertions, 13 deletions
diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py
index d3692f8..a379d33 100755
--- a/Lib/test/re_tests.py
+++ b/Lib/test/re_tests.py
@@ -106,8 +106,8 @@ tests = [
('a.*b', 'acc\nccb', FAIL),
('a.{4,5}b', 'acc\nccb', FAIL),
('a.b', 'a\rb', SUCCEED, 'found', 'a\rb'),
- ('a.b(?s)', 'a\nb', SUCCEED, 'found', 'a\nb'),
- ('a.*(?s)b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'),
+ ('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'),
+ ('(?s)a.*b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'),
('(?s)a.{4,5}b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'),
('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'),
@@ -563,7 +563,7 @@ tests = [
# Check odd placement of embedded pattern modifiers
# not an error under PCRE/PRE:
- ('w(?i)', 'W', SUCCEED, 'found', 'W'),
+ ('(?i)w', 'W', SUCCEED, 'found', 'W'),
# ('w(?i)', 'W', SYNTAX_ERROR),
# Comments using the x embedded pattern modifier
@@ -627,7 +627,7 @@ xyzabc
# bug 114033: nothing to repeat
(r'(x?)?', 'x', SUCCEED, 'found', 'x'),
# bug 115040: rescan if flags are modified inside pattern
- (r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'),
+ (r'(?x) foo ', 'foo', SUCCEED, 'found', 'foo'),
# bug 115618: negative lookahead
(r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
# bug 116251: character class bug
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index a5f5832..fb74246 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -62,14 +62,14 @@ class FnmatchTestCase(unittest.TestCase):
class TranslateTestCase(unittest.TestCase):
def test_translate(self):
- self.assertEqual(translate('*'), r'.*\Z(?ms)')
- self.assertEqual(translate('?'), r'.\Z(?ms)')
- self.assertEqual(translate('a?b*'), r'a.b.*\Z(?ms)')
- self.assertEqual(translate('[abc]'), r'[abc]\Z(?ms)')
- self.assertEqual(translate('[]]'), r'[]]\Z(?ms)')
- self.assertEqual(translate('[!x]'), r'[^x]\Z(?ms)')
- self.assertEqual(translate('[^x]'), r'[\^x]\Z(?ms)')
- self.assertEqual(translate('[x'), r'\[x\Z(?ms)')
+ self.assertEqual(translate('*'), r'(?s:.*)\Z')
+ self.assertEqual(translate('?'), r'(?s:.)\Z')
+ self.assertEqual(translate('a?b*'), r'(?s:a.b.*)\Z')
+ self.assertEqual(translate('[abc]'), r'(?s:[abc])\Z')
+ self.assertEqual(translate('[]]'), r'(?s:[]])\Z')
+ self.assertEqual(translate('[!x]'), r'(?s:[^x])\Z')
+ self.assertEqual(translate('[^x]'), r'(?s:[\^x])\Z')
+ self.assertEqual(translate('[x'), r'(?s:\[x)\Z')
class FilterTestCase(unittest.TestCase):
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 06c10c1..2cff1c5 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -158,7 +158,7 @@ class PyclbrTest(TestCase):
cm('cgi', ignore=('log',)) # set with = in module
cm('pickle', ignore=('partial',))
cm('aifc', ignore=('openfp', '_aifc_params')) # set with = in module
- cm('sre_parse', ignore=('dump', 'groups')) # from sre_constants import *; property
+ cm('sre_parse', ignore=('dump', 'groups', 'pos')) # from sre_constants import *; property
cm('pdb')
cm('pydoc')
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index afe8738..79a7a05 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1279,6 +1279,9 @@ class ReTests(unittest.TestCase):
self.assertTrue(re.match('(?ixu) ' + upper_char, lower_char))
self.assertTrue(re.match('(?ixu) ' + lower_char, upper_char))
+ with self.assertWarns(DeprecationWarning):
+ self.assertTrue(re.match(upper_char + '(?i)', lower_char))
+
def test_dollar_matches_twice(self):
"$ matches the end of string, and just before the terminating \n"
pattern = re.compile('$')