-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
executable file
·28 lines (26 loc) · 2.52 KB
/
test.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
#!/usr/bin/python
import sys
import os
import unittest
import tests
def runtests():
# based on Smart's test.py:
loader = unittest.TestLoader()
runner = unittest.TextTestRunner()
testsdir = os.path.dirname(tests.__file__)
filenames = os.listdir(testsdir)
failure_count = 0
test_count = 0
for filename in filenames:
if (filename != "__init__.py" and filename.endswith(".py")
and filename.startswith("test_")):
modname = tests.__name__+ "." + filename[:-3]
module = __import__(modname, None, None, [modname])
testcase = loader.loadTestsFromModule(module)
result = runner.run(testcase)
failure_count += len(result.failures)
test_count += testcase.countTestCases()
print "total: fails: %d, tests: %d" % (failure_count,
test_count)
if __name__ == "__main__":
runtests()