-
Notifications
You must be signed in to change notification settings - Fork 4
/
AllTests.py
executable file
·91 lines (73 loc) · 2.69 KB
/
AllTests.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python2
"""AllTests.py - This module runs the automated tests in all the components.
To run specific test cases, pass one or more names of package/module names
on the command line which contain the test cases to be run.
Usage:
python AllTests.py - Runs all the unittests
python AllTests.py mypackage.MyFile - Runs the tests in 'mypackage/MyFile'
"""
alltestnames = [
'WebUtils.Tests.TestFuncs',
'WebUtils.Tests.TestFieldStorage',
'WebUtils.Tests.TestHTMLTag.makeTestSuite',
'MiscUtils.Tests.TestCSVParser',
'MiscUtils.Tests.TestNamedValueAccess.makeTestSuite',
'MiscUtils.Tests.TestError',
'MiscUtils.Tests.TestFuncs',
'MiscUtils.Tests.TestPickleCache',
'MiscUtils.Tests.TestDataTable',
'MiscUtils.Tests.TestDateInterval',
'MiscUtils.Tests.TestDateParser',
'MiscUtils.Tests.TestDictForArgs',
'WebKit.Tests.SessionStoreTest',
'WebKit.Tests.Basic.Test',
'TaskKit.Tests.Test.makeTestSuite',
'PSP.Tests.TestContext',
'PSP.Tests.TestUtils',
'PSP.Tests.TestBraceConverter',
'PSP.Tests.TestCompiler',
'UserKit.Tests.ExampleTest',
'UserKit.Tests.RoleTest',
'UserKit.Tests.UserManagerTest.makeTestSuite',
]
import site
import sys
import unittest
import logging
if __name__ == '__main__':
# Configure logging
logging.basicConfig() # default level is WARN
print
print
# If no arguments are given, all of the test cases are run.
if len(sys.argv) == 1:
testnames = alltestnames
verbosity = 2
logging.getLogger().setLevel(logging.INFO)
print 'Loading all Webware Tests...'
else:
testnames = sys.argv[1:]
# Turn up verbosity and logging level
verbosity = 3
logging.getLogger().setLevel(logging.DEBUG)
print 'Loading tests %s...' % testnames
tests = unittest.TestSuite()
# We could just use defaultTestLoader.loadTestsFromNames(),
# but it doesn't give a good error message when it cannot load a test.
# So we load all tests individually and raise appropriate exceptions.
for test in testnames:
try:
tests.addTest(unittest.defaultTestLoader.loadTestsFromName(test))
except Exception:
print 'ERROR: Skipping tests from "%s".' % test
try: # just try to import the test after loading failed
__import__(test)
except ImportError:
print 'Could not import the test module.'
else:
print 'Could not load the test suite.'
from traceback import print_exc
print_exc()
print
print 'Running the tests...'
unittest.TextTestRunner(verbosity=verbosity).run(tests)