~0x44/nova/bug838466

« back to all changes in this revision

Viewing changes to run_tests.py

  • Committer: Tarmac
  • Author(s): termie
  • Date: 2011-02-23 18:46:38 UTC
  • mfrom: (715.2.2 more_run_tests)
  • Revision ID: tarmac-20110223184638-wbouu3zmrdztozrr
Adds some features to run_tests.sh:
- if it crashes right away with a short erorr log, print that directly
- allow specifying tests without the nova.tests part

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#    See the License for the specific language governing permissions and
18
18
#    limitations under the License.
19
19
 
 
20
"""Unittest runner for Nova.
 
21
 
 
22
To run all tests
 
23
    python run_tests.py
 
24
 
 
25
To run a single test:
 
26
    python run_tests.py test_compute:ComputeTestCase.test_run_terminate
 
27
 
 
28
To run a single test module:
 
29
    python run_tests.py test_compute
 
30
 
 
31
    or
 
32
 
 
33
    python run_tests.py api.test_wsgi
 
34
 
 
35
"""
 
36
 
20
37
import gettext
21
38
import os
22
39
import unittest
62
79
 
63
80
if __name__ == '__main__':
64
81
    logging.setup()
 
82
    # If any argument looks like a test name but doesn't have "nova.tests" in
 
83
    # front of it, automatically add that so we don't have to type as much
 
84
    argv = []
 
85
    for x in sys.argv:
 
86
        if x.startswith('test_'):
 
87
            argv.append('nova.tests.%s' % x)
 
88
        else:
 
89
            argv.append(x)
 
90
 
65
91
    c = config.Config(stream=sys.stdout,
66
92
                      env=os.environ,
67
93
                      verbosity=3,
70
96
    runner = NovaTestRunner(stream=c.stream,
71
97
                            verbosity=c.verbosity,
72
98
                            config=c)
73
 
    sys.exit(not core.run(config=c, testRunner=runner))
 
99
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))