在Python(3.3.2)doctest中,省略号(...
)可以匹配任何字符串.下面的代码
def foo():
"""
>>> foo()
hello ...
"""
print("hello world")
当运行doctest时,它不应该引发任何错误.但是
$ python -m doctest foo.py
**********************************************************************
File "./foo.py", line 3, in foo.foo
Failed example:
foo()
Expected:
hello ...
Got:
hello world
**********************************************************************
1 items had failures:
1 of 1 in foo.foo
***Test Failed*** 1 failures.
我必须做什么才能让ellipis?据我所知,默认情况下它是禁用的.
我知道像下面的代码一样,add # doctest: +ELLIPSIS
可以解决这个问题,但我喜欢为所有测试启用省略号.
def foo():
"""
>>> foo() # doctest: +ELLIPSIS
hello ...
"""
print("hello world")