/trunk/Examples/test-suite/python/exception_order_runme.py

# · Python · 43 lines · 32 code · 9 blank · 2 comment · 11 complexity · b41cb80dbed84c5ca71e46786a392e7d MD5 · raw file

  1. from exception_order import *
  2. # This test is expected to fail with -builtin option.
  3. # Throwing builtin classes as exceptions not supported
  4. a = A()
  5. try:
  6. a.foo()
  7. except E1,e:
  8. pass
  9. except:
  10. raise RuntimeError, "bad exception order"
  11. try:
  12. a.bar()
  13. except E2,e:
  14. pass
  15. except:
  16. raise RuntimeError, "bad exception order"
  17. try:
  18. a.foobar()
  19. except RuntimeError,e:
  20. if e.args[0] != "postcatch unknown":
  21. print "bad exception order",
  22. raise RuntimeError, e.args
  23. try:
  24. a.barfoo(1)
  25. except E1,e:
  26. pass
  27. except:
  28. raise RuntimeError, "bad exception order"
  29. try:
  30. a.barfoo(2)
  31. except E2,e:
  32. pass
  33. except:
  34. raise RuntimeError, "bad exception order"