summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-29 22:01:48 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-29 22:01:48 (GMT)
commit07360df481adeacfc2b7a1a7f89ae9a76e86b725 (patch)
tree1d111118cafc0117d3cd68fdfa7397e68dd25191 /Lib/test/test_re.py
parent1813c1701f8e7e9287bccf66d1b4b8348c432168 (diff)
downloadcpython-07360df481adeacfc2b7a1a7f89ae9a76e86b725.zip
cpython-07360df481adeacfc2b7a1a7f89ae9a76e86b725.tar.gz
cpython-07360df481adeacfc2b7a1a7f89ae9a76e86b725.tar.bz2
Issue #14260: The groupindex attribute of regular expression pattern object
now is non-modifiable mapping.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 020656a..5b71612 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -577,6 +577,14 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.match("(a)", "a").regs, ((0, 1), (0, 1)))
self.assertTrue(re.match("(a)", "a").re)
+ # Issue 14260. groupindex should be non-modifiable mapping.
+ p = re.compile(r'(?i)(?P<first>a)(?P<other>b)')
+ self.assertEqual(sorted(p.groupindex), ['first', 'other'])
+ self.assertEqual(p.groupindex['other'], 2)
+ with self.assertRaises(TypeError):
+ p.groupindex['other'] = 0
+ self.assertEqual(p.groupindex['other'], 2)
+
def test_special_escapes(self):
self.assertEqual(re.search(r"\b(b.)\b",
"abcd abc bcd bx").group(1), "bx")