-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·38 lines (29 loc) · 849 Bytes
/
test.py
File metadata and controls
executable file
·38 lines (29 loc) · 849 Bytes
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
#!/bin/env python
#
# Test.py
#
'''
Test.py -- Generic unit test runner. Imports all modules in ./test and runs them all.
'''
import unittest
import os
import re
TESTFILEGLOB="\S*test\S*.py\Z"
testdirfiles= os.listdir("./test")
p = re.compile(TESTFILEGLOB, re.IGNORECASE)
modulestotest=[]
for pyfile in testdirfiles:
m = p.match(pyfile)
if m:
pyfilebase = os.path.basename(pyfile)
(modname,ext) = os.path.splitext(pyfilebase)
modulestotest.append(modname)
def suite():
alltests = unittest.TestSuite()
for module in modulestotest:
modulePath="%s.%s" % ("test", module)
aModule = __import__(modulePath, globals(), locals(), [''])
alltests.addTest(unittest.findTestCases(aModule))
return alltests
if __name__ == '__main__':
unittest.main(defaultTest='suite')