def test_copy_function_doc_to_method_doc():
 def f1(object, a, b, c):
  'Docstring for f1\n\n        Parameters\n        ----------\n        object : object\n            Some object. This description also has\n\n            blank lines in it.\n        a : int\n            Parameter a\n        b : int\n            Parameter b\n        '
  pass
 def f2(object):
  'Docstring for f2\n\n        Parameters\n        ----------\n        object : object\n            Only one parameter\n\n        Returns\n        -------\n        nothing.\n        '
  pass
 def f3(object):
  'Docstring for f3\n\n        Parameters\n        ----------\n        object : object\n            Only one parameter\n        '
  pass
 def f4(object):
  'Docstring for f4'
  pass
 def f5(object):
  'Docstring for f5\n\n        Parameters\n        ----------\n        Returns\n        -------\n        nothing.\n        '
  pass
 class A:
  @copy_function_doc_to_method_doc(f1)
  def method_f1(self, a, b, c):
   pass
  @copy_function_doc_to_method_doc(f2)
  def method_f2(self):
   'method_f3 own docstring'
   pass
  @copy_function_doc_to_method_doc(f3)
  def method_f3(self):
   pass
 assert_equal(A.method_f1.__doc__, 'Docstring for f1\n\n        Parameters\n        ----------\n        a : int\n            Parameter a\n        b : int\n            Parameter b\n        ')
 assert_equal(A.method_f2.__doc__, 'Docstring for f2\n\n        Returns\n        -------\n        nothing.\n        method_f3 own docstring')
 assert_equal(A.method_f3.__doc__, 'Docstring for f3\n\n        ')
 assert_raises(ValueError, copy_function_doc_to_method_doc(f4), A.method_f1)
 assert_raises(ValueError, copy_function_doc_to_method_doc(f5), A.method_f1)

def test_copy_function_doc_to_method_doc ( ) : def f1 ( object , a , b , c ) : pass def f2 ( object ) : pass def f3 ( object ) : pass def f4 ( object ) : pass def f5 ( object ) : pass class A : @ copy_function_doc_to_method_doc ( f1 ) def method_f1 ( self , a , b , c ) : pass @ copy_function_doc_to_method_doc ( f2 ) def method_f2 ( self ) : pass @ copy_function_doc_to_method_doc ( f3 ) def method_f3 ( self ) : pass assert_equal ( A . method_f1 . __doc__ , 'Docstring for f1\n\n        Parameters\n        ----------\n        a : int\n            Parameter a\n        b : int\n            Parameter b\n        ' ) assert_equal ( A . method_f2 . __doc__ , 'Docstring for f2\n\n        Returns\n        -------\n        nothing.\n        method_f3 own docstring' ) assert_equal ( A . method_f3 . __doc__ , 'Docstring for f3\n\n        ' ) assert_raises ( ValueError , copy_function_doc_to_method_doc ( f4 ) , A . method_f1 ) assert_raises ( ValueError , copy_function_doc_to_method_doc ( f5 ) , A . method_f1 )
test decorator for re-using function docstring as method docstrings .