forked from firi/appengine-btree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
43 lines (36 loc) · 1.15 KB
/
run_tests.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
#!/usr/bin/python
#
# Scripts that help set up all proper paths for
# unittests and then runs the tests. Adapted from:
# https://cloud.google.com/appengine/docs/python/tools/localunittesting
#
import optparse
import sys
import unittest
USAGE = """%prog SDK_PATH
Run unit tests for App Engine apps.
SDK_PATH Path to the SDK installation"""
def main(sdk_path):
sys.path.insert(0, sdk_path)
import api_server
api_server.fix_sys_path()
# Use this to run a particular test during development
# from btree import btree_test
# fast = unittest.TestSuite()
# fast.addTest(btree_test.BTreeTest('test_get_or_create'))
# unittest.TextTestRunner().run(fast)
# Runs all tests
suite = unittest.loader.TestLoader().\
discover('.', pattern='*_test.py')
result = unittest.TextTestRunner(verbosity=2).run(suite)
if not result.wasSuccessful():
sys.exit(1)
if __name__ == '__main__':
parser = optparse.OptionParser(USAGE)
options, args = parser.parse_args()
if len(args) != 1:
print 'Error: Exactly 1 arguments required.'
parser.print_help()
sys.exit(1)
SDK_PATH = args[0]
main(SDK_PATH)