def test_function_name_carrying_with_decorator(self): function_docstring = 'foo' @decorators.restful_pagination() def _function_to_decorate(): raise NotImplementedError _function_to_decorate.__doc__ = function_docstring self.assertNotEqual( decorators.restful_pagination().__name__, _function_to_decorate.__name__ ) self.assertEqual(function_docstring, _function_to_decorate.__doc__)
def test_function_name_preservation(self): """ Result of a bug that occurred with the decorator, in that the wrapped function was not passing the name and docstring of ``f``. This resulted in Sphinx being unable to write the docstring of the wrapped function """ def _function_to_decorate(): raise NotImplementedError function_name = _function_to_decorate.__name__ function_doc = _function_to_decorate.__doc__ decorated_function = \ decorators.restful_pagination()(_function_to_decorate) self.assertEqual(decorated_function.__name__, function_name) self.assertEqual(decorated_function.__doc__, function_doc)