def with_ioloop(method, expect_success=True):
 def test_method(self):
  r = method(self)
  loop = self.io_loop
  if expect_success:
   self.pullstream.on_recv(self.on_message_succeed)
  else:
   self.pullstream.on_recv(self.on_message_fail)
  loop.call_later(1, self.attempt_connection)
  loop.call_later(1.2, self.send_msg)
  if expect_success:
   loop.call_later(2, self.on_test_timeout_fail)
  else:
   loop.call_later(2, self.on_test_timeout_succeed)
  loop.start()
  if self.fail_msg:
   self.fail(self.fail_msg)
  return r
 return test_method

def with_ioloop ( method , expect_success = True ) : def test_method ( self ) : r = method ( self ) loop = self . io_loop if expect_success : self . pullstream . on_recv ( self . on_message_succeed ) else : self . pullstream . on_recv ( self . on_message_fail ) loop . call_later ( 1 , self . attempt_connection ) loop . call_later ( 1.2 , self . send_msg ) if expect_success : loop . call_later ( 2 , self . on_test_timeout_fail ) else : loop . call_later ( 2 , self . on_test_timeout_succeed ) loop . start ( ) if self . fail_msg : self . fail ( self . fail_msg ) return r return test_method
decorator for running tests with an ioloop .