~nchohan/appscale/zk3.3.4

« back to all changes in this revision

Viewing changes to AppServer/lib/webapp2/run_tests.py

  • Committer: Chris Bunch
  • Date: 2012-02-17 08:19:21 UTC
  • mfrom: (787.2.3 appscale-raj-merge)
  • Revision ID: cgb@cs.ucsb.edu-20120217081921-pakidyksaenlpzur
merged with main branch, gaining rabbitmq and upgrades for hbase, cassandra, and hypertable, as well as upgrading to gae 1.6.1 for python and go

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import sys
 
3
import unittest
 
4
 
 
5
gae_path = '/usr/local/google_appengine'
 
6
 
 
7
current_path = os.path.abspath(os.path.dirname(__file__))
 
8
tests_path = os.path.join(current_path, 'tests')
 
9
sys.path[0:0] = [
 
10
    current_path,
 
11
    tests_path,
 
12
    gae_path,
 
13
    # All libs used by webapp2 and extras.
 
14
    os.path.join(current_path, 'lib', 'appengine-ndb-experiment'),
 
15
    os.path.join(current_path, 'lib', 'babel'),
 
16
    os.path.join(current_path, 'lib', 'Jinja2-2.6'),
 
17
    os.path.join(current_path, 'lib', 'Mako-0.4.1'),
 
18
    os.path.join(current_path, 'lib', 'gaepytz-2011h'),
 
19
    os.path.join(current_path, 'lib', 'WebOb-1.0.8'),
 
20
    # SDK libs.
 
21
    os.path.join(gae_path, 'lib', 'django_0_96'),
 
22
    #os.path.join(gae_path, 'lib', 'webob'),
 
23
    os.path.join(gae_path, 'lib', 'yaml', 'lib'),
 
24
    os.path.join(gae_path, 'lib', 'protorpc'),
 
25
    os.path.join(gae_path, 'lib', 'simplejson'),
 
26
]
 
27
 
 
28
all_tests = [f[:-8] for f in os.listdir(tests_path) if f.endswith('_test.py')]
 
29
 
 
30
def get_suite(tests):
 
31
    tests = sorted(tests)
 
32
    suite = unittest.TestSuite()
 
33
    loader = unittest.TestLoader()
 
34
    for test in tests:
 
35
        suite.addTest(loader.loadTestsFromName(test))
 
36
    return suite
 
37
 
 
38
if __name__ == '__main__':
 
39
    """
 
40
    To run all tests:
 
41
        $ python run_tests.py
 
42
    To run a single test:
 
43
        $ python run_tests.py app
 
44
    To run a couple of tests:
 
45
        $ python run_tests.py app config sessions
 
46
    To run code coverage:
 
47
        $ coverage run run_tests.py
 
48
        $ coverage report -m
 
49
    """
 
50
    tests = sys.argv[1:]
 
51
    if not tests:
 
52
        tests = all_tests
 
53
    tests = ['%s_test' % t for t in tests]
 
54
    suite = get_suite(tests)
 
55
    unittest.TextTestRunner(verbosity=2).run(suite)