mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
test class exceptions
This commit is contained in:
parent
077793581d
commit
6de668f3aa
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user