]> granicus.if.org Git - python/commitdiff
add minimal test of exception use. verify that each exception can be
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 20 Jun 2000 18:52:57 +0000 (18:52 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 20 Jun 2000 18:52:57 +0000 (18:52 +0000)
raised, caught, and converted to a string.

Lib/test/test_exceptions.py

index d172ecd153b06c55ad63c542239e97edb4b6479a..7bc515c488613fd80164b80f5ca49b097a8b911a 100644 (file)
@@ -6,7 +6,19 @@ from types import ClassType
 print '5. Built-in exceptions'
 # XXX This is not really enough, each *operation* should be tested!
 
+def test_raise_catch(exc):
+    try:
+        raise exc, "spam"
+    except exc, err:
+        buf = str(err)
+    try:
+        raise exc("spam")
+    except exc, err:
+        buf = str(err)
+    print buf
+
 def r(thing):
+    test_raise_catch(thing)
     if type(thing) == ClassType:
         print thing.__name__
     else: