summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-03-06 09:36:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-03-06 09:36:15 (GMT)
commita537eb45fd964dea378e78efa6c576dc00666f2a (patch)
treee9561816f372d734b7c1e1cad56b2511ca757c50 /Lib/test/test_re.py
parente6a537976e918cca58c1b8c52fd4557b360bb3f8 (diff)
parentccdf352370da4acf2c3f1c77e4a21bc954b4dcf6 (diff)
downloadcpython-a537eb45fd964dea378e78efa6c576dc00666f2a.zip
cpython-a537eb45fd964dea378e78efa6c576dc00666f2a.tar.gz
cpython-a537eb45fd964dea378e78efa6c576dc00666f2a.tar.bz2
Issue #20283: RE pattern methods now accept the string keyword parameters
as documented. The pattern and source keyword parameters are left as deprecated aliases.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index a229e23..33ccd15 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1205,6 +1205,24 @@ class ReTests(unittest.TestCase):
self.assertEqual(out.getvalue().splitlines(),
['literal 102 ', 'literal 111 ', 'literal 111 '])
+ def test_keyword_parameters(self):
+ # Issue #20283: Accepting the string keyword parameter.
+ pat = re.compile(r'(ab)')
+ self.assertEqual(
+ pat.match(string='abracadabra', pos=7, endpos=10).span(), (7, 9))
+ self.assertEqual(
+ pat.fullmatch(string='abracadabra', pos=7, endpos=9).span(), (7, 9))
+ self.assertEqual(
+ pat.search(string='abracadabra', pos=3, endpos=10).span(), (7, 9))
+ self.assertEqual(
+ pat.findall(string='abracadabra', pos=3, endpos=10), ['ab'])
+ self.assertEqual(
+ pat.split(string='abracadabra', maxsplit=1),
+ ['', 'ab', 'racadabra'])
+ self.assertEqual(
+ pat.scanner(string='abracadabra', pos=3, endpos=10).search().span(),
+ (7, 9))
+
class PatternReprTests(unittest.TestCase):
def check(self, pattern, expected):