From 32f3add26737afdbca6eda2edc3d27e6d315fc8e Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Mon, 28 Oct 2002 17:58:48 +0000 Subject: [PATCH] Add a test of interaction between & and extra replacements. 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 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 3c5b11ab265..af97888793c 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -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", {"å" : "å"}) == "Hei på deg" +def test_unescape_amp_extra(): + return unescape("&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)))