forked from coto/gae-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testrunner.py
47 lines (37 loc) · 1.27 KB
/
testrunner.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
#!/usr/bin/python
import optparse
import sys
import unittest
import os
USAGE = """%prog SDK_PATH TEST_PATH
Run unit test for App Engine apps.
SDK_PATH Path to the SDK installation
TEST_PATH Path to package containing test modules"""
def main(sdk_path, test_path):
"""
Run the tests using testrunner.py script in the project root directory.
Usage: testrunner.py SDK_PATH TEST_PATH
Run unit tests for App Engine apps.
SDK_PATH Path to the SDK installation
TEST_PATH Path to package containing test modules
Options:
-h, --help show this help message and exit
"""
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'bp_includes/external'))
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
suite = unittest.loader.TestLoader().discover(test_path)
result = unittest.TextTestRunner(verbosity=2).run(suite)
exit_code = 0 if result.wasSuccessful() else 1
sys.exit(exit_code)
if __name__ == '__main__':
parser = optparse.OptionParser(USAGE)
options, args = parser.parse_args()
if len(args) != 2:
print 'Error: Exactly 2 arguments required.'
parser.print_help()
sys.exit(1)
SDK_PATH = args[0]
TEST_PATH = args[1]
main(SDK_PATH, TEST_PATH)