summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-07-17 14:52:48 (GMT)
committerGuido van Rossum <guido@python.org>1997-07-17 14:52:48 (GMT)
commita0e4c1bffc3454345fd79708e9e43a2412ce1197 (patch)
tree890eed283933ac77a039f0ded1bb6b6c091e1175 /Lib/test/test_re.py
parent75fce308bc79ab1f0774e9b3f61031121994e5df (diff)
downloadcpython-a0e4c1bffc3454345fd79708e9e43a2412ce1197.zip
cpython-a0e4c1bffc3454345fd79708e9e43a2412ce1197.tar.gz
cpython-a0e4c1bffc3454345fd79708e9e43a2412ce1197.tar.bz2
Jeffrey's latest -- seems to solve most problems!
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index f1b270d..6b8c65d 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1,5 +1,10 @@
+#!/usr/local/bin/python
+# -*- mode: python -*-
+# $Id$
+
from test_support import verbose
import re
+import reop
import sys, os, string, traceback
from re_tests import *
@@ -7,6 +12,7 @@ if verbose: print 'Running re_tests test suite'
for t in tests:
print t
+ sys.stdout.flush()
pattern=s=outcome=repl=expected=None
if len(t)==5:
pattern, s, outcome, repl, expected = t
@@ -21,6 +27,8 @@ for t in tests:
if outcome==SYNTAX_ERROR: pass # Expected a syntax error
else:
print '=== Syntax error:', t
+ except KeyboardInterrupt:
+ raise KeyboardInterrupt
except:
print '*** Unexpected error ***'
if verbose:
@@ -28,7 +36,7 @@ for t in tests:
else:
try:
result=obj.search(s)
- except regex.error, msg:
+ except (re.error, reop.error), msg:
print '=== Unexpected exception', t, repr(msg)
if outcome==SYNTAX_ERROR:
# This should have been a syntax error; forget it.
@@ -41,22 +49,26 @@ for t in tests:
# Matched, as expected, so now we compute the
# result string and compare it to our expected result.
start, end = result.span(0)
- vardict={'found': result.group(0), 'groups': result.group()}
+ vardict={'found': result.group(0),
+ 'groups': result.group(),
+ 'flags': result.re.flags}
for i in range(1, 100):
try:
gi = result.group(i)
# Special hack because else the string concat fails:
- if gi is None: gi = "None"
+ if gi is None:
+ gi = "None"
except IndexError:
gi = "Error"
vardict['g%d' % i] = gi
for i in result.re.groupindex.keys():
try:
gi = result.group(i)
+ if gi is None:
+ gi = "None"
except IndexError:
- pass
- else:
- vardict[i] = str(gi)
+ gi = "Error"
+ vardict[i] = gi
repl=eval(repl, vardict)
if repl!=expected:
print '=== grouping error', t,