I felt that doctest.testfile () would be useful, so make a note
dcotest.testmod () is testing the example in the comments in the source code I thought this was also useful, but I tend to get a lot of comments
example.txt
Example of hoge
python hoge.py -v
=========================
adder() receives two arguments and returns
the sum of them
>>> from hoge import adder
>>> adder(1, 2)
3
>>> adder('doc', 'test')
'doctest'
hoge.py
import doctest
def adder(a, b):
return a + b
if __name__ == "__main__":
doctest.testfile('./example.txt')
Recommended Posts