@@ -298,6 +298,32 @@ def test_re_split(self):
298298 # with self.subTest(sep=sep), self.assertRaises(ValueError):
299299 # self.assertTypedEqual(re.split(sep, ':a:b::c'), expected)
300300
301+ def test_re_findall (self ):
302+ self .assertEqual (re .findall (":+" , "abc" ), [])
303+ for string in "a:b::c:::d" , S ("a:b::c:::d" ):
304+ self .assertTypedEqual (re .findall (":+" , string ),
305+ [":" , "::" , ":::" ])
306+ self .assertTypedEqual (re .findall ("(:+)" , string ),
307+ [":" , "::" , ":::" ])
308+ self .assertTypedEqual (re .findall ("(:)(:*)" , string ),
309+ [(":" , "" ), (":" , ":" ), (":" , "::" )])
310+ for string in (b"a:b::c:::d" , B (b"a:b::c:::d" ), bytearray (b"a:b::c:::d" ),
311+ memoryview (b"a:b::c:::d" )):
312+ self .assertTypedEqual (re .findall (b":+" , string ),
313+ [b":" , b"::" , b":::" ])
314+ self .assertTypedEqual (re .findall (b"(:+)" , string ),
315+ [b":" , b"::" , b":::" ])
316+ self .assertTypedEqual (re .findall (b"(:)(:*)" , string ),
317+ [(b":" , b"" ), (b":" , b":" ), (b":" , b"::" )])
318+ for x in ("\xe0 " , "\u0430 " , "\U0001d49c " ):
319+ xx = x * 2
320+ xxx = x * 3
321+ string = "a%sb%sc%sd" % (x , xx , xxx )
322+ self .assertEqual (re .findall ("%s+" % x , string ), [x , xx , xxx ])
323+ self .assertEqual (re .findall ("(%s+)" % x , string ), [x , xx , xxx ])
324+ self .assertEqual (re .findall ("(%s)(%s*)" % (x , x ), string ),
325+ [(x , "" ), (x , x ), (x , xx )])
326+
301327 def test_ignore_case_set (self ):
302328 self .assertTrue (re .match (r'[19A]' , 'A' , re .I ))
303329 self .assertTrue (re .match (r'[19a]' , 'a' , re .I ))
0 commit comments