From b02f8fc3afe6a8632f8898b990615e51244e23af Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 25 Sep 2016 20:36:23 +0300 Subject: [PATCH] Issue #11957: Restored re tests for passing count and maxsplit as positional arguments. --- Lib/test/test_re.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index f415f3f8c4b..0834fe0f403 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -102,6 +102,8 @@ class ReTests(unittest.TestCase): self.assertEqual(re.sub("(?i)b+", "x", "bbbb BBBB"), 'x x') self.assertEqual(re.sub(r'\d+', self.bump_num, '08.2 -2 23x99y'), '9.3 -3 24x100y') + self.assertEqual(re.sub(r'\d+', self.bump_num, '08.2 -2 23x99y', 3), + '9.3 -3 23x99y') self.assertEqual(re.sub(r'\d+', self.bump_num, '08.2 -2 23x99y', count=3), '9.3 -3 23x99y') @@ -206,6 +208,7 @@ class ReTests(unittest.TestCase): def test_qualified_re_sub(self): self.assertEqual(re.sub('a', 'b', 'aaaaa'), 'bbbbb') + self.assertEqual(re.sub('a', 'b', 'aaaaa', 1), 'baaaa') self.assertEqual(re.sub('a', 'b', 'aaaaa', count=1), 'baaaa') def test_bug_114660(self): @@ -291,6 +294,7 @@ class ReTests(unittest.TestCase): self.assertEqual(re.subn("b+", "x", "bbbb BBBB"), ('x BBBB', 1)) self.assertEqual(re.subn("b+", "x", "xyz"), ('xyz', 0)) self.assertEqual(re.subn("b*", "x", "xyz"), ('xxxyxzx', 4)) + self.assertEqual(re.subn("b*", "x", "xyz", 2), ('xxxyz', 2)) self.assertEqual(re.subn("b*", "x", "xyz", count=2), ('xxxyz', 2)) def test_re_split(self): @@ -347,6 +351,7 @@ class ReTests(unittest.TestCase): self.assertTypedEqual(re.split(sep, ':a:b::c'), expected) def test_qualified_re_split(self): + self.assertEqual(re.split(":", ":a:b::c", 2), ['', 'a', 'b::c']) self.assertEqual(re.split(":", ":a:b::c", maxsplit=2), ['', 'a', 'b::c']) self.assertEqual(re.split(':', 'a:b:c:d', maxsplit=2), ['a', 'b', 'c:d']) self.assertEqual(re.split("(:)", ":a:b::c", maxsplit=2),