self.finished = True
+ def test_with_method_args(self):
+ @gen_test
+ def test_with_args(self, *args):
+ self.assertEqual(args, ('test',))
+ yield gen.Task(self.io_loop.add_callback)
+
+ test_with_args(self, 'test')
+ self.finished = True
+
+ def test_with_method_kwargs(self):
+ @gen_test
+ def test_with_kwargs(self, **kwargs):
+ self.assertDictEqual(kwargs, {'test': 'test'})
+ yield gen.Task(self.io_loop.add_callback)
+
+ test_with_kwargs(self, test='test')
+ self.finished = True
+
if __name__ == '__main__':
unittest.main()
# This is a good case study arguing for either some sort of
# extensibility in the gen decorators or cancellation support.
@functools.wraps(f)
- def pre_coroutine(self):
- result = f(self)
+ def pre_coroutine(self, *args, **kwargs):
+ result = f(self, *args, **kwargs)
if isinstance(result, types.GeneratorType):
self._test_generator = result
else:
coro = gen.coroutine(pre_coroutine)
@functools.wraps(coro)
- def post_coroutine(self):
+ def post_coroutine(self, *args, **kwargs):
try:
return self.io_loop.run_sync(
- functools.partial(coro, self), timeout=timeout)
+ functools.partial(coro, self, *args, **kwargs),
+ timeout=timeout)
except TimeoutError as e:
# run_sync raises an error with an unhelpful traceback.
# If we throw it back into the generator the stack trace