/
run_tests.py
executable file
·48 lines (40 loc) · 1.33 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
44
45
46
47
48
#!/usr/bin/env python
from __future__ import unicode_literals
import sys
import unittest
import argparse
from tests import base, related
from tests.dynamic import fields as dyn_fields, related as dyn_related
if __name__ == "__main__":
# Define arguments
parser = argparse.ArgumentParser(description="Run redis-limpyd-extensions tests suite.")
parser.add_argument(
"tests",
nargs="*",
default=None,
help="Tests (module, TestCase or TestCaseMethod) to run. "
"use full path, eg.: `tests.module.Class.test` ; "
"`tests.module.Class` works also ; `tests.module` too!"
)
parser.add_argument(
"-v",
"--verbosity",
type=int,
action="store",
dest="verbosity",
default=2,
help="Verbosity of the runner."
)
args = parser.parse_args()
if args.tests:
# we have names
suite = unittest.TestLoader().loadTestsFromNames(args.tests)
else:
# Run all the tests
suites = []
for mod in [base, related, dyn_fields, dyn_related]:
suite = unittest.TestLoader().loadTestsFromModule(mod)
suites.append(suite)
suite = unittest.TestSuite(suites)
result = unittest.TextTestRunner(verbosity=args.verbosity).run(suite)
sys.exit(not result.wasSuccessful())