[Python-checkins] CVS: python/dist/src/Lib/test test_re.py,1.22,1.23
Fredrik Lundh
python-dev@python.org
Tue, 8 Aug 2000 09:47:44 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv9622/lib/test
Modified Files:
test_re.py
Log Message:
-- whitespace cleanup (more tests to be added in the next commit)
Index: test_re.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** test_re.py 2000/08/03 12:16:29 1.22
--- test_re.py 2000/08/08 16:47:42 1.23
***************
*** 38,42 ****
try:
assert re.sub("(?i)b+", "x", "bbbb BBBB") == 'x x'
!
def bump_num(matchobj):
int_value = int(matchobj.group(0))
--- 38,42 ----
try:
assert re.sub("(?i)b+", "x", "bbbb BBBB") == 'x x'
!
def bump_num(matchobj):
int_value = int(matchobj.group(0))
***************
*** 45,49 ****
assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y'
assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y', 3) == '9.3 -3 23x99y'
!
assert re.sub('.', lambda m: r"\n", 'x') == '\\n'
assert re.sub('.', r"\n", 'x') == '\n'
--- 45,49 ----
assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y'
assert re.sub(r'\d+', bump_num, '08.2 -2 23x99y', 3) == '9.3 -3 23x99y'
!
assert re.sub('.', lambda m: r"\n", 'x') == '\\n'
assert re.sub('.', r"\n", 'x') == '\n'
***************
*** 51,55 ****
s = r"\1\1"
assert re.sub('(.)', s, 'x') == 'xx'
! assert re.sub('(.)', re.escape(s), 'x') == s
assert re.sub('(.)', lambda m: s, 'x') == s
--- 51,55 ----
s = r"\1\1"
assert re.sub('(.)', s, 'x') == 'xx'
! assert re.sub('(.)', re.escape(s), 'x') == s
assert re.sub('(.)', lambda m: s, 'x') == s
***************
*** 147,151 ****
if verbose:
print 'Running tests on re.split'
!
try:
assert re.split(":", ":a:b::c") == ['', 'a', 'b', '', 'c']
--- 147,151 ----
if verbose:
print 'Running tests on re.split'
!
try:
assert re.split(":", ":a:b::c") == ['', 'a', 'b', '', 'c']
***************
*** 166,170 ****
assert re.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
! assert re.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
except AssertionError:
raise TestFailed, "qualified re.split"
--- 166,170 ----
assert re.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
! assert re.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c']
except AssertionError:
raise TestFailed, "qualified re.split"
***************
*** 188,201 ****
try:
# No groups at all
! m = re.match('a', 'a') ; assert m.groups() == ()
# A single group
! m = re.match('(a)', 'a') ; assert m.groups() == ('a',)
pat = re.compile('((a)|(b))(c)?')
! assert pat.match('a').groups() == ('a', 'a', None, None)
! assert pat.match('b').groups() == ('b', None, 'b', None)
! assert pat.match('ac').groups() == ('a', 'a', None, 'c')
! assert pat.match('bc').groups() == ('b', None, 'b', 'c')
! assert pat.match('bc').groups("") == ('b', "", 'b', 'c')
except AssertionError:
raise TestFailed, "match .groups() method"
--- 188,201 ----
try:
# No groups at all
! m = re.match('a', 'a') ; assert m.groups() == ()
# A single group
! m = re.match('(a)', 'a') ; assert m.groups() == ('a',)
pat = re.compile('((a)|(b))(c)?')
! assert pat.match('a').groups() == ('a', 'a', None, None)
! assert pat.match('b').groups() == ('b', None, 'b', None)
! assert pat.match('ac').groups() == ('a', 'a', None, 'c')
! assert pat.match('bc').groups() == ('b', None, 'b', 'c')
! assert pat.match('bc').groups("") == ('b', "", 'b', 'c')
except AssertionError:
raise TestFailed, "match .groups() method"
***************
*** 203,214 ****
try:
# A single group
! m = re.match('(a)', 'a')
! assert m.group(0) == 'a' ; assert m.group(0) == 'a'
assert m.group(1) == 'a' ; assert m.group(1, 1) == ('a', 'a')
pat = re.compile('(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?')
! assert pat.match('a').group(1, 2, 3) == ('a', None, None)
! assert pat.match('b').group('a1', 'b2', 'c3') == (None, 'b', None)
! assert pat.match('ac').group(1, 'b2', 3) == ('a', None, 'c')
except AssertionError:
raise TestFailed, "match .group() method"
--- 203,214 ----
try:
# A single group
! m = re.match('(a)', 'a')
! assert m.group(0) == 'a' ; assert m.group(0) == 'a'
assert m.group(1) == 'a' ; assert m.group(1, 1) == ('a', 'a')
pat = re.compile('(?:(?P<a1>a)|(?P<b2>b))(?P<c3>c)?')
! assert pat.match('a').group(1, 2, 3) == ('a', None, None)
! assert pat.match('b').group('a1', 'b2', 'c3') == (None, 'b', None)
! assert pat.match('ac').group(1, 'b2', 3) == ('a', None, 'c')
except AssertionError:
raise TestFailed, "match .group() method"
***************
*** 243,248 ****
assert re.L == re.LOCALE
assert re.M == re.MULTILINE
! assert re.S == re.DOTALL
! assert re.X == re.VERBOSE
except AssertionError:
raise TestFailed, 're module constants'
--- 243,248 ----
assert re.L == re.LOCALE
assert re.M == re.MULTILINE
! assert re.S == re.DOTALL
! assert re.X == re.VERBOSE
except AssertionError:
raise TestFailed, 're module constants'
***************
*** 261,265 ****
# To save time, only run the first and last 10 tests
#tests = tests[:10] + tests[-10:]
! pass
for t in tests:
--- 261,265 ----
# To save time, only run the first and last 10 tests
#tests = tests[:10] + tests[-10:]
! pass
for t in tests:
***************
*** 269,273 ****
pattern, s, outcome, repl, expected = t
elif len(t)==3:
! pattern, s, outcome = t
else:
raise ValueError, ('Test tuples should have 3 or 5 fields',t)
--- 269,273 ----
pattern, s, outcome, repl, expected = t
elif len(t)==3:
! pattern, s, outcome = t
else:
raise ValueError, ('Test tuples should have 3 or 5 fields',t)
***************
*** 277,281 ****
except re.error:
if outcome==SYNTAX_ERROR: pass # Expected a syntax error
! else:
print '=== Syntax error:', t
except KeyboardInterrupt: raise KeyboardInterrupt
--- 277,281 ----
except re.error:
if outcome==SYNTAX_ERROR: pass # Expected a syntax error
! else:
print '=== Syntax error:', t
except KeyboardInterrupt: raise KeyboardInterrupt
***************
*** 331,335 ****
# break (because it won't match at the end or start of a
# string), so we'll ignore patterns that feature it.
!
if pattern[:2]!='\\B' and pattern[-2:]!='\\B' and result!=None:
obj=re.compile(pattern)
--- 331,335 ----
# break (because it won't match at the end or start of a
# string), so we'll ignore patterns that feature it.
!
if pattern[:2]!='\\B' and pattern[-2:]!='\\B' and result!=None:
obj=re.compile(pattern)