blob: e0f249081fd724f54fa59ebf3098cbaee4a8306b [file] [log] [blame]
Yesudeep Mangalapillyaaa9ac62011-08-11 01:31:24 +05301#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4import os
5import sys
6import unittest2 as unittest
7
8current_path = os.path.abspath(os.path.dirname(__file__))
9tests_path = os.path.join(current_path, 'tests')
10sys.path[0:0] = [
11 current_path,
12 tests_path,
13]
14
15all_tests = [f[:-3] for f in os.listdir(tests_path)
16 if f.startswith('test_') and f.endswith(".py")]
17
18def get_suite(tests):
19 tests = sorted(tests)
20 suite = unittest.TestSuite()
21 loader = unittest.TestLoader()
22 for test in tests:
23 suite.addTest(loader.loadTestsFromName(test))
24 return suite
25
26if __name__ == '__main__':
27 """
28 To run all tests:
29 $ python run_tests.py
30 To run a single test:
31 $ python run_tests.py app
32 To run a couple of tests:
33 $ python run_tests.py app config sessions
34 To run code coverage:
35 $ coverage run run_tests.py
36 $ coverage report -m
37 """
38 tests = sys.argv[1:]
39 if not tests:
40 tests = all_tests
41 tests = ['%s' % t for t in tests]
42 suite = get_suite(tests)
43 unittest.TextTestRunner(verbosity=1).run(suite)