2828except :
2929 raise TestFailed , "re.search"
3030
31- # Try nasty case that overflows the straightforward recursive
32- # implementation of repeated groups.
33- #assert re.match('(x)*', 50000*'x').span() == (0, 50000)
34-
3531if verbose :
3632 print 'Running tests on re.sub'
3733
@@ -154,8 +150,8 @@ def bump_num(matchobj):
154150 assert re .split ("(?::*)" , ":a:b::c" ) == ['' , 'a' , 'b' , 'c' ]
155151 assert re .split ("(:)*" , ":a:b::c" ) == ['' , ':' , 'a' , ':' , 'b' , ':' , 'c' ]
156152 assert re .split ("([b:]+)" , ":a:b::c" ) == ['' , ':' , 'a' , ':b::' , 'c' ]
157- ## assert re.split("(b)|(:+)", ":a:b::c") == \
158- ## ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c']
153+ assert re .split ("(b)|(:+)" , ":a:b::c" ) == \
154+ ['' , None , ':' , 'a' , None , ':' , '' , 'b' , None , '' , None , '::' , 'c' ]
159155 assert re .split ("(?:b)|(?::+)" , ":a:b::c" ) == ['' , 'a' , '' , '' , 'c' ]
160156except AssertionError :
161157 raise TestFailed , "re.split"
@@ -253,6 +249,16 @@ def bump_num(matchobj):
253249 except :
254250 print 'Exception raised on flag' , flags
255251
252+ if verbose :
253+ print 'Test engine limitations'
254+
255+ # Try nasty case that overflows the straightforward recursive
256+ # implementation of repeated groups.
257+ try :
258+ assert re .match ('(x)*' , 50000 * 'x' ).span () == (0 , 50000 )
259+ except RuntimeError , v :
260+ print v
261+
256262from re_tests import *
257263
258264if verbose :
@@ -326,6 +332,19 @@ def bump_num(matchobj):
326332 else :
327333 print '=== Failed incorrectly' , t
328334
335+ # Try the match on a unicode string, and check that it
336+ # still succeeds.
337+ result = obj .search (unicode (s , "latin-1" ))
338+ if result == None :
339+ print '=== Fails on unicode match' , t
340+
341+ # Try the match on a unicode pattern, and check that it
342+ # still succeeds.
343+ obj = re .compile (unicode (pattern , "latin-1" ))
344+ result = obj .search (s )
345+ if result == None :
346+ print '=== Fails on unicode pattern match' , t
347+
329348 # Try the match with the search area limited to the extent
330349 # of the match and see if it still succeeds. \B will
331350 # break (because it won't match at the end or start of a
@@ -350,3 +369,10 @@ def bump_num(matchobj):
350369 result = obj .search (s )
351370 if result == None :
352371 print '=== Fails on locale-sensitive match' , t
372+
373+ # Try the match with UNICODE locale enabled, and check
374+ # that it still succeeds.
375+ obj = re .compile (pattern , re .UNICODE )
376+ result = obj .search (s )
377+ if result == None :
378+ print '=== Fails on unicode-sensitive match' , t
0 commit comments