]> granicus.if.org Git - python/commitdiff
Add a test of interaction between & and extra replacements.
authorFred Drake <fdrake@acm.org>
Mon, 28 Oct 2002 17:58:48 +0000 (17:58 +0000)
committerFred Drake <fdrake@acm.org>
Mon, 28 Oct 2002 17:58:48 +0000 (17:58 +0000)
Remove extra noise from the output when there are no errors, and say more
in the exception when there are errors.

Lib/test/test_sax.py

index 3c5b11ab26567757a005bd612aab81f184725119..af97888793cb68e9883e3d1a98dc2ef5966e9321 100644 (file)
@@ -19,17 +19,17 @@ import os
 # ===== Utilities
 
 tests = 0
-fails = 0
+failures = []
 
 def confirm(outcome, name):
-    global tests, fails
+    global tests
 
     tests = tests + 1
     if outcome:
-        print "Passed", name
+        if verbose:
+            print "Failed", name
     else:
-        print "Failed", name
-        fails = fails + 1
+        failures.append(name)
 
 def test_make_parser2():
     try:
@@ -82,6 +82,9 @@ def test_unescape_all():
 def test_unescape_extra():
     return unescape("Hei på deg", {"å" : "&aring;"}) == "Hei p&aring; deg"
 
+def test_unescape_amp_extra():
+    return unescape("&amp;foo;", {"&foo;": "splat"}) == "&foo;"
+
 # ===== quoteattr
 
 def test_quoteattr_basic():
@@ -650,6 +653,8 @@ for (name, value) in items:
     if name[ : 5] == "test_":
         confirm(value(), name)
 
-print "%d tests, %d failures" % (tests, fails)
-if fails != 0:
-    raise TestFailed, "%d of %d tests failed" % (fails, tests)
+if verbose:
+    print "%d tests, %d failures" % (tests, len(failures))
+if failures:
+    raise TestFailed("%d of %d tests failed: %s"
+                     % (len(failures), tests, ", ".join(failures)))