mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
add minimal test of exception use. verify that each exception can be
raised, caught, and converted to a string.
This commit is contained in:
parent
2d15d9d869
commit
56c807d318
1 changed files with 12 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue