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