-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathtest_doc.py
executable file
·50 lines (38 loc) · 1.19 KB
/
test_doc.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
from doctest import testfile, ELLIPSIS, testmod
from sys import exit, path as sys_path
from os.path import dirname
def testDoc(filename, name=None):
print("--- %s: Run tests" % filename)
failure, nb_test = testfile(
filename, optionflags=ELLIPSIS, name=name)
if failure:
exit(1)
print("--- %s: End of tests" % filename)
def importModule(name):
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
def testModule(name):
print("--- Test module %s" % name)
module = importModule(name)
failure, nb_test = testmod(module)
if failure:
exit(1)
print("--- End of test")
def main():
ptrace_dir = dirname(__file__)
sys_path.append(ptrace_dir)
# Test documentation in doc/*.rst files
# testDoc('doc/c_tools.rst')
# Test documentation of some functions/classes
testModule("ptrace.ctypes_tools")
testModule("ptrace.debugger.parse_expr")
testModule("ptrace.logging_tools")
testModule("ptrace.signames")
testModule("ptrace.syscall.socketcall")
testModule("ptrace.tools")
if __name__ == "__main__":
main()