-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_doc.py
53 lines (43 loc) · 1.33 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
51
52
#!/usr/bin/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():
fusil_dir = dirname(__file__)
sys_path.append(fusil_dir)
# Test documentation in doc/*.rst files
testDoc('doc/c_tools.rst')
testDoc('doc/file_watch.rst')
testDoc('doc/mangle.rst')
testDoc('doc/process.rst')
# Unit tests as reST
testDoc('tests/file_watch_read.rst')
testDoc('tests/file_watch_ignore.rst')
testDoc('tests/cmd_help_parser.rst')
# Test documentation of some functions/classes
testModule("fusil.bits")
testModule("fusil.tools")
testModule("fusil.process.replay_python")
testModule("fusil.process.tools")
if __name__ == "__main__":
main()