和
def show(a):
""" Shows a string
>>> show(a)
a
"""
print(a)
def test():
import doctest
doctest.testmod()
if __name__ == '__main__': test()
我在尝试了解文档字符串的工作方式时遇到错误。这个方法和从命令行运行它
python -m doctest unittest.py
以错误结束。
Traceback (most recent call last):
File "/home/liquid/workspace/MyPythonProject/src/unittest.py", line 19, in <module>
if __name__ == '__main__': test()
File "/home/liquid/workspace/MyPythonProject/src/unittest.py", line 16, in test
import doctest
File "/usr/lib/python3.2/doctest.py", line 2105, in <module>
class DocTestCase(unittest.TestCase):
AttributeError: 'module' object has no attribute 'TestCase'
为什么?