Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e6d571

Browse files
author
Fredrik Lundh
committed
-- enabled some temporarily disabled RE tests
-- added basic unicode tests to test_re -- added test case for Sjoerd's xmllib problem to re_tests
1 parent 2643b55 commit 8e6d571

3 files changed

Lines changed: 39 additions & 6 deletions

File tree

Lib/test/output/test_re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test_re
2+
maximum recursion limit exceeded

Lib/test/re_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,4 +587,10 @@
587587
('\t\n\v\r\f\a\g', '\t\n\v\r\f\ag', SUCCEED, 'found', '\t\n\v\r\f\ag'),
588588
(r'\t\n\v\r\f\a', '\t\n\v\r\f\a', SUCCEED, 'found', chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)),
589589
(r'[\t][\n][\v][\r][\f][\b]', '\t\n\v\r\f\b', SUCCEED, 'found', '\t\n\v\r\f\b'),
590+
591+
# additional regression tests (1.6 and later)
592+
593+
# xmllib problem
594+
(r'(([a-z]+):)?([a-z]+)$', 'smil', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-smil'),
595+
590596
]

Lib/test/test_re.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
except:
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-
3531
if 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']
160156
except 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+
256262
from re_tests import *
257263

258264
if 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

Comments
 (0)