Doctest:在多行上拆分Python函数调用的docstring
我想知道是否有一种方法可以在doctest的多行上分割函数调用。例如,对于类似Doctest:在多行上拆分Python函数调用的docstring,python,nosetests,docstring,doctest,Python,Nosetests,Docstring,Doctest,我想知道是否有一种方法可以在doctest的多行上分割函数调用。例如,对于类似 >>> result = some_func(some_param=1, another_param=4, a_third_param='super_long_string') 我试过了 >>> result = some_func(some_param=1, another_param=4, ... a_third_param='super_long_stri
>>> result = some_func(some_param=1, another_param=4, a_third_param='super_long_string')
我试过了
>>> result = some_func(some_param=1, another_param=4,
... a_third_param='super_long_string')
或 但两者都不起作用。有什么想法或建议吗 编辑:
我通过
nosetests-sv运行doctests——使用doctest
您的第二个示例非常接近于适合我的示例。在我放了一组椭圆之后,我加了五个空格
我添加五个空格的原因是,第一个空格与提示符匹配,另外四个空格与缩进级别匹配
下面是一个使用Python2.7和您提供的函数的示例
def some_func(some_param, another_param, a_third_param):
"""
Does something at least some of the time.
Examples
--------
>>> some_func(
... some_param=1,
... another_param=4,
... a_third_param='super_long_string')
'Worked'
"""
return 'Worked'
if __name__ == "__main__":
import doctest
doctest.testmod()
对不起,在我上面的例子中,这是一个输入错误。我还尝试了
…
之后的5个空格,但同样的问题的前导空格不一致
,但感谢您的帮助!我想这个问题是特定于nosetests-sv--with doctest
命令的。我正在使用python 3.4.0和nose 1.3.4
>>> result = some_func(#doctest: +NORMALIZE_WHITESPACE
some_param=1,
another_param=4,
a_third_param='super_long_string')
def some_func(some_param, another_param, a_third_param):
"""
Does something at least some of the time.
Examples
--------
>>> some_func(
... some_param=1,
... another_param=4,
... a_third_param='super_long_string')
'Worked'
"""
return 'Worked'
if __name__ == "__main__":
import doctest
doctest.testmod()