File: test_doc.py

package info (click to toggle)
python-ptrace 0.7-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 680 kB
  • ctags: 1,002
  • sloc: python: 6,659; ansic: 263; makefile: 13; sh: 1
file content (45 lines) | stat: -rwxr-xr-x 1,176 bytes parent folder | download
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
#!/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.tools")
    testModule("ptrace.signames")
    testModule("ptrace.logging_tools")
    testModule("ptrace.debugger.parse_expr")
    testModule("ptrace.syscall.socketcall")

if __name__ == "__main__":
    main()