我在Python中做了一個類來執行一些基本的操作。爲什麼doctest失敗?
class perform(object):
def add(self, first, second):
"""Adds two numbers
>>>perform().add(1, 2)
3
Also adds string
>>>perform().add('some', 'thing')
'something'
"""
return first+second
我不明白爲什麼doctest的add
函數失敗。
不文檔測試確切地告訴你它爲什麼失敗? – juanchopanza
請注意,文檔中涵蓋了:https://docs.python.org/2/library/doctest.html#how-are-docstring-examples-recognized – jonrsharpe