THRIFT-3602 Make Tornado server send exception on unexpected handler error
Client: py

This closes #839
This closes #1425
diff --git a/test/py.tornado/test_suite.py b/test/py.tornado/test_suite.py
index 32d1c2e..447fde6 100755
--- a/test/py.tornado/test_suite.py
+++ b/test/py.tornado/test_suite.py
@@ -21,8 +21,8 @@
 
 import datetime
 import glob
-import sys
 import os
+import sys
 import time
 import unittest
 
@@ -40,8 +40,8 @@
 from tornado.testing import AsyncTestCase, get_unused_port, gen_test
 
 from thrift import TTornado
+from thrift.Thrift import TApplicationException
 from thrift.protocol import TBinaryProtocol
-from thrift.transport.TTransport import TTransportException
 
 from ThriftTest import ThriftTest
 from ThriftTest.ttypes import Xception, Xtruct
@@ -55,6 +55,8 @@
         pass
 
     def testString(self, s):
+        if s == 'unexpected_error':
+            raise Exception(s)
         return s
 
     def testByte(self, b):
@@ -85,7 +87,7 @@
             x.message = s
             raise x
         elif s == 'throw_undeclared':
-            raise ValueError("foo")
+            raise ValueError('testing undeclared exception')
 
     def testOneway(self, seconds):
         start = time.time()
@@ -97,6 +99,7 @@
         self.test_instance.io_loop.add_timeout(
             datetime.timedelta(seconds=seconds),
             fire_oneway)
+        raise Exception('testing exception in oneway method')
 
     def testNest(self, thing):
         return thing
@@ -187,10 +190,11 @@
         self.assertEqual(y.i32_thing, -3)
         self.assertEqual(y.i64_thing, -5)
 
+    @gen_test
     def test_oneway(self):
-        self.client.testOneway(0)
-        start, end, seconds = self.wait(timeout=1)
-        self.assertAlmostEqual(seconds, (end - start), places=3)
+        self.client.testOneway(1)
+        v = yield self.client.testI32(-1)
+        self.assertEqual(v, -1)
 
     @gen_test
     def test_map(self):
@@ -203,8 +207,6 @@
 
     @gen_test
     def test_exception(self):
-        yield self.client.testException('Safe')
-
         try:
             yield self.client.testException('Xception')
         except Xception as ex:
@@ -214,11 +216,13 @@
             self.fail("should have gotten exception")
         try:
             yield self.client.testException('throw_undeclared')
-        except TTransportException as ex:
+        except TApplicationException:
             pass
         else:
             self.fail("should have gotten exception")
 
+        yield self.client.testException('Safe')
+
 
 def suite():
     suite = unittest.TestSuite()