| from __future__ import absolute_import, division, with_statement |
| import sys |
| import unittest |
| |
| from tornado.util import raise_exc_info |
| |
| |
| class RaiseExcInfoTest(unittest.TestCase): |
| def test_two_arg_exception(self): |
| # This test would fail on python 3 if raise_exc_info were simply |
| # a three-argument raise statement, because TwoArgException |
| # doesn't have a "copy constructor" |
| class TwoArgException(Exception): |
| def __init__(self, a, b): |
| super(TwoArgException, self).__init__() |
| self.a, self.b = a, b |
| |
| try: |
| raise TwoArgException(1, 2) |
| except TwoArgException: |
| exc_info = sys.exc_info() |
| try: |
| raise_exc_info(exc_info) |
| self.fail("didn't get expected exception") |
| except TwoArgException, e: |
| self.assertTrue(e is exc_info[1]) |