def _assert_transport_is_closed_on_error(self, sock, loop):
     port = sock.getsockname()[1]
     client_manager = yield from create_client(
         Sleep.Client,
         host='localhost',
         port=port,
         loop=loop,
     )
     try:
         with client_manager as client:
             raise Exception('expected exception from test')
     except:
         self.assertFalse(client._oprot.trans.isOpen())
 def _assert_transport_is_closed_on_error(self, sock, loop):
     port = sock.getsockname()[1]
     client_manager = yield from create_client(
         Sleep.Client,
         host='localhost',
         port=port,
         loop=loop,
     )
     try:
         with client_manager as client:
             raise Exception('expected exception from test')
     except:
         self.assertFalse(client._oprot.trans.isOpen())
 def _make_out_of_order_calls(self, sock, loop):
     port = sock.getsockname()[1]
     client_manager = yield from create_client(
         Sleep.Client,
         host='localhost',
         port=port,
         loop=loop,
     )
     with client_manager as client:
         futures = [
             client.echo(str(delay), delay * .1) for delay in [3, 2, 1]
         ]
         results_in_arrival_order = []
         for f in asyncio.as_completed(futures, loop=loop):
             result = yield from f
             results_in_arrival_order.append(result)
         self.assertEquals(['1', '2', '3'], results_in_arrival_order)
 def _make_out_of_order_calls(self, sock, loop):
     port = sock.getsockname()[1]
     client_manager = yield from create_client(
         Sleep.Client,
         host='localhost',
         port=port,
         loop=loop,
     )
     with client_manager as client:
         futures = [
             client.echo(str(delay), delay * .1)
             for delay in [3, 2, 1]
         ]
         results_in_arrival_order = []
         for f in asyncio.as_completed(futures, loop=loop):
             result = yield from f
             results_in_arrival_order.append(result)
         self.assertEquals(['1', '2', '3'], results_in_arrival_order)