1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/python
import inspect
import os
import sys
import testdoc
from testdoc import documenter, finder, formatter, reflect
def usage():
return "Usage: testdoc <fully-qualified module name>"
def string_to_module(argument):
if os.path.exists(argument):
return reflect.filenameToModule(argument)
obj = reflect.namedAny(argument)
if not inspect.ismodule(obj):
raise ValueError('%r is not a Python module' % (argument,))
def main():
if len(sys.argv) != 2:
print usage()
sys.exit(2)
try:
module = string_to_module(sys.argv[1])
except:
print usage()
raise
format = formatter.WikiFormatter(sys.stdout)
doc = documenter.Documenter(format)
finder.find_tests(doc, module)
if __name__ == '__main__':
main()
|