私は、スケーリングではなくdoctestについて提起された上記のすべての点に同意し、unittestに固執することを好みます。
私が貢献できるヒントの1つは、コード処理から単体テストを呼び出すこと__name__ == "__main__
です。これにより、テストファイルをスクリプトとして実行すると、テストが実行されます。
例えば:
#!/usr/bin/env python
"""
Unit tests for the GetFiles.py utility
"""
import unittest
from FileUtilities import getTree
class TestFileUtilities(unittest.TestCase):
def testGetTree(self):
"""
Tests that a known tree is found and incidentally confirms
that we have the tree we expected to use for our current
sample extraction.
"""
found = getTree('./anzmeta-dtd', '.pen')
expected_path_tail = ['ISOdia.pen',
'ISOgrk1.pen',
'ISOtech.pen']
for i, full_path in enumerate(found):
assert full_path.endswith( expected_path_tail[i] ), expected_path_tail[i]
# other tests elided
if __name__ == "__main__":
# When this module is executed from the command-line, run all its tests
unittest.main()