test class exceptions

This commit is contained in:
Guido van Rossum 1995-02-09 10:28:43 +00:00
parent 077793581d
commit 6de668f3aa
1 changed files with 36 additions and 0 deletions

View File

@ -21,3 +21,39 @@ for i in range(10):
n = n+i
if n <> 90:
raise TestFailed, 'try inside for'
print '2.2 raise class exceptions'
class AClass: pass
class BClass(AClass): pass
class CClass: pass
try: raise AClass()
except: pass
try: raise AClass()
except AClass: pass
try: raise BClass()
except AClass: pass
try: raise BClass()
except CClass: raise TestFailed
except: pass
a = AClass()
b = BClass()
try: raise AClass, b
except BClass, v: raise TestFailed
except AClass, v:
if v != b: raise TestFailed
try: raise b
except AClass, v:
if v != b: raise TestFailed
try: raise BClass, a
except TypeError: pass