-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·44 lines (34 loc) · 1.13 KB
/
run_tests.py
File metadata and controls
executable file
·44 lines (34 loc) · 1.13 KB
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
#!/usr/bin/env python
import unittest
import doctest
import os
import os.path
import glob
from test.calc_example import TestCalc
from test.expr_example import TestExpr
from test.json_example import TestJson
tests = [ TestCalc,
TestExpr,
TestJson ]
doc_dirs = [ "",
"doc/" ]
def convert_to_unix_line_endings(source):
assert os.path.isfile(source) # ensures we're in the correct directory
if not os.path.isdir("tmp"):
os.mkdir("tmp")
dest = "tmp/" + os.path.basename(source)
source_file = open(source, "r")
dest_file = open(dest, "w")
dest_file.writelines(source_file)
dest_file.close()
source_file.close()
return dest
doc_files = []
for doc_dir in doc_dirs:
doc_files.extend(glob.glob(doc_dir + "*.txt"))
tmp_doc_files = [convert_to_unix_line_endings(file) for file in doc_files]
suites = [ unittest.TestLoader().loadTestsFromTestCase(test) for test in tests ] + \
[ doctest.DocFileTest(file, module_relative = False) for file in tmp_doc_files ]
unittest.TextTestRunner(verbosity = 2).run(unittest.TestSuite(suites))
for file in tmp_doc_files:
os.remove(file)