summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-16 22:29:58 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-16 22:29:58 (GMT)
commitabf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b (patch)
treed5d1e22046efaa0a779f4a387ba8622b900234fe /Lib/test/test_re.py
parent8761e59f360baefd4cead71d77de48ed91c3cfb7 (diff)
downloadcpython-abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b.zip
cpython-abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b.tar.gz
cpython-abf275af5804c5f76fbe10c5cb1dd3d2e4b04c5b.tar.bz2
Issue #22493: Warning message emitted by using inline flags in the middle of
regular expression now contains a (truncated) regex pattern. Patch by Tim Graham.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index eb1aba3..6803e02 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1323,8 +1323,21 @@ 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))
+ p = upper_char + '(?i)'
+ with self.assertWarns(DeprecationWarning) as warns:
+ self.assertTrue(re.match(p, lower_char))
+ self.assertEqual(
+ str(warns.warnings[0].message),
+ 'Flags not at the start of the expression %s' % p
+ )
+
+ p = upper_char + '(?i)%s' % ('.?' * 100)
+ with self.assertWarns(DeprecationWarning) as warns:
+ self.assertTrue(re.match(p, lower_char))
+ self.assertEqual(
+ str(warns.warnings[0].message),
+ 'Flags not at the start of the expression %s (truncated)' % p[:20]
+ )
def test_dollar_matches_twice(self):
"$ matches the end of string, and just before the terminating \n"