util_test.py
Go to the documentation of this file.
00001 from __future__ import absolute_import, division, with_statement
00002 import sys
00003 import unittest
00004 
00005 from tornado.util import raise_exc_info
00006 
00007 
00008 class RaiseExcInfoTest(unittest.TestCase):
00009     def test_two_arg_exception(self):
00010         # This test would fail on python 3 if raise_exc_info were simply
00011         # a three-argument raise statement, because TwoArgException
00012         # doesn't have a "copy constructor"
00013         class TwoArgException(Exception):
00014             def __init__(self, a, b):
00015                 super(TwoArgException, self).__init__()
00016                 self.a, self.b = a, b
00017 
00018         try:
00019             raise TwoArgException(1, 2)
00020         except TwoArgException:
00021             exc_info = sys.exc_info()
00022         try:
00023             raise_exc_info(exc_info)
00024             self.fail("didn't get expected exception")
00025         except TwoArgException, e:
00026             self.assertTrue(e is exc_info[1])


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Thu Jan 2 2014 11:53:55