]> granicus.if.org Git - python/commitdiff
Tweak re_tests and test_re to differentiate between
authorGuido van Rossum <guido@python.org>
Tue, 15 Jul 1997 15:49:52 +0000 (15:49 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 15 Jul 1997 15:49:52 +0000 (15:49 +0000)
groups that have no value and groups that are out of bounds.

Lib/test/output/test_re
Lib/test/re_tests.py
Lib/test/test_re.py

index 182ca054e3b903796d44df736b946695b2a2438c..c806244e06b18515e7222ddc6e934d5dd3deb255 100644 (file)
@@ -59,7 +59,7 @@ test_re
 ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
 === Syntax error: ('()ef', 'def', 0, 'found+"-"+g1', 'ef-')
 ('$b', 'b', 1)
-('a\\(b', 'a(b', 0, 'found+"-"+g1', 'a(b-None')
+('a\\(b', 'a(b', 0, 'found+"-"+g1', 'a(b-Error')
 ('a\\(*b', 'ab', 0, 'found', 'ab')
 ('a\\(*b', 'a((b', 0, 'found', 'a((b')
 ('a\\\\b', 'a\\b', 0, 'found', 'a\\b')
index 393e2b2c92deb3991792bbaa3eab12258be4f2c7..5c48fccdb78c1e3bc090bbfcbcdc63c71caf055a 100755 (executable)
@@ -34,8 +34,10 @@ benchmarks = [
 #         3: a string that will be eval()'ed to produce a test string.
 #            This is an arbitrary Python expression; the available
 #            variables are "found" (the whole match), and "g1", "g2", ...
-#            up to "g10" contain the contents of each group, or the
-#            string 'None' if the group wasn't given a value.
+#            up to "g99" contain the contents of each group, or the
+#            string 'None' if the group wasn't given a value, or the
+#            string 'Error' if the group index was out of range;
+#            also "groups", the return value of m.group() (a tuple).
 #         4: The expected result of evaluating the expression.
 #            If the two don't match, an error is reported.
 #
@@ -137,7 +139,7 @@ tests = [
  'found+"-"+g1', 'ef-'),
 ('$b', 'b', FAIL),
 ('a\\(b', 'a(b', SUCCEED,
- 'found+"-"+g1', 'a(b-None'),
+ 'found+"-"+g1', 'a(b-Error'),
 ('a\\(*b', 'ab', SUCCEED,
  'found', 'ab'),
 ('a\\(*b', 'a((b', SUCCEED,
index cef14b0822905a7a29609721da9b73af8beaca50..33e9e54b6fa36d29a7e66d60e33c97daa86c1123 100644 (file)
@@ -48,7 +48,7 @@ for t in tests:
                        # Special hack because else the string concat fails:
                        if gi is None: gi = "None"
                    except IndexError:
-                       gi = "None"
+                       gi = "Error"
                    vardict['g%d' % i] = gi
                repl=eval(repl, vardict)
                if repl!=expected: