diff options
author | Guido van Rossum <guido@python.org> | 1995-02-09 10:28:43 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-02-09 10:28:43 (GMT) |
commit | 6de668f3aa4acb93c0e54be12af4d23adb95370a (patch) | |
tree | de03c43bb2c6fd1f3dc26de17451ff457f392011 | |
parent | 077793581da358d74789e09f10fa944105ee98d3 (diff) | |
download | cpython-6de668f3aa4acb93c0e54be12af4d23adb95370a.zip cpython-6de668f3aa4acb93c0e54be12af4d23adb95370a.tar.gz cpython-6de668f3aa4acb93c0e54be12af4d23adb95370a.tar.bz2 |
test class exceptions
-rw-r--r-- | Lib/test/test_opcodes.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py index 4cc6ee9..b1e944b 100644 --- a/Lib/test/test_opcodes.py +++ b/Lib/test/test_opcodes.py @@ -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 |