summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-03-19 14:09:45 (GMT)
committerGitHub <noreply@github.com>2022-03-19 14:09:45 (GMT)
commit906f1a4a95e9ca82171a40a28b16533a14fa339c (patch)
treefccdb6d24098bd35d9c39419af0b803a7741fe8b /Lib/test/test_re.py
parentc1f327f30db09388fc777196e233b7a6182c6efa (diff)
downloadcpython-906f1a4a95e9ca82171a40a28b16533a14fa339c.zip
cpython-906f1a4a95e9ca82171a40a28b16533a14fa339c.tar.gz
cpython-906f1a4a95e9ca82171a40a28b16533a14fa339c.tar.bz2
bpo-39394: Improve warning message in the re module (GH-31988)
A warning about inline flags not at the start of the regular expression now contains the position of the flag. (cherry picked from commit 4142961b9f5ad3bf93976a6a7162f8049e354018) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 588cc79..3d06378 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1444,7 +1444,8 @@ class ReTests(unittest.TestCase):
self.assertTrue(re.match(p, lower_char))
self.assertEqual(
str(warns.warnings[0].message),
- 'Flags not at the start of the expression %r' % p
+ 'Flags not at the start of the expression %r'
+ ' but at position 1' % p
)
self.assertEqual(warns.warnings[0].filename, __file__)
@@ -1453,7 +1454,8 @@ class ReTests(unittest.TestCase):
self.assertTrue(re.match(p, lower_char))
self.assertEqual(
str(warns.warnings[0].message),
- 'Flags not at the start of the expression %r (truncated)' % p[:20]
+ 'Flags not at the start of the expression %r (truncated)'
+ ' but at position 1' % p[:20]
)
self.assertEqual(warns.warnings[0].filename, __file__)
@@ -1465,7 +1467,8 @@ class ReTests(unittest.TestCase):
self.assertTrue(re.match(p, b'a'))
self.assertEqual(
str(warns.warnings[0].message),
- 'Flags not at the start of the expression %r' % p
+ 'Flags not at the start of the expression %r'
+ ' but at position 1' % p
)
self.assertEqual(warns.warnings[0].filename, __file__)