6
doctest에서 줄임표 (...
)는 모든 문자열과 일치 할 수 있습니다. 따라서 doctest를 실행할 때python doctest를 호출 할 때 줄임표를 사용하는 방법
def foo():
"""
>>> foo()
hello ...
"""
print("hello world")
을 입력하면 오류가 발생하지 않습니다. 하지만
$ 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를 사용하려면 어떻게해야합니까? 내가 말할 수있는 한 기본적으로 비활성화되어 있습니다.
나는 아래 코드에서와 같이 # doctest: +ELLIPSIS
을 추가하는 것으로 알고 있지만 모든 테스트에서 줄임표를 사용하고 싶습니다.
def foo():
"""
>>> foo() # doctest: +ELLIPSIS
hello ...
"""
print("hello world")