def gen_test(func=None, timeout=None):
 if (timeout is None):
  timeout = get_async_test_timeout()
 def wrap(f):
  @functools.wraps(f)
  def pre_coroutine(self, *args, **kwargs):
   result = f(self, *args, **kwargs)
   if (isinstance(result, GeneratorType) or iscoroutine(result)):
    self._test_generator = result
   else:
    self._test_generator = None
   return result
  if iscoroutinefunction(f):
   coro = pre_coroutine
  else:
   coro = gen.coroutine(pre_coroutine)
  @functools.wraps(coro)
  def post_coroutine(self, *args, **kwargs):
   try:
    return self.io_loop.run_sync(functools.partial(coro, self, *args, **kwargs), timeout=timeout)
   except TimeoutError as e:
    self._test_generator.throw(e)
    raise
  return post_coroutine
 if (func is not None):
  return wrap(func)
 else:
  return wrap

def gen_test ( func = None , timeout = None ) : if ( timeout is None ) : timeout = get_async_test_timeout ( ) def wrap ( f ) : @ functools . wraps ( f ) def pre_coroutine ( self , * args , ** kwargs ) : result = f ( self , * args , ** kwargs ) if ( isinstance ( result , GeneratorType ) or iscoroutine ( result ) ) : self . _test_generator = result else : self . _test_generator = None return result if iscoroutinefunction ( f ) : coro = pre_coroutine else : coro = gen . coroutine ( pre_coroutine ) @ functools . wraps ( coro ) def post_coroutine ( self , * args , ** kwargs ) : try : return self . io_loop . run_sync ( functools . partial ( coro , self , * args , ** kwargs ) , timeout = timeout ) except TimeoutError as e : self . _test_generator . throw ( e ) raise return post_coroutine if ( func is not None ) : return wrap ( func ) else : return wrap
testing equivalent of @gen .