forked from Twangist/log_calls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
executable file
·40 lines (30 loc) · 1.07 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
#! /usr/bin/env python3
import os
import sys
import unittest
def usage_exit():
"""Usage: <path>/run_tests.py [-v | -q | -h]
<path> is the path to the directory containing run_tests.py.
Use . if running it from its own directory.
All tests in <path>/tests/ are run.
-v Verbose output, each test that's run is listed.
-q Quiet(est) output.
-h Display this message.
"""
exit(usage_exit.__doc__)
if __name__ == '__main__':
verbosity = 1
if len(sys.argv) > 1:
arg = sys.argv[1].upper()
if arg.startswith("-H"): usage_exit()
if arg.startswith("-Q"): verbosity = 0
elif arg.startswith("-V"): verbosity = 2
cd = os.getcwd()
home, _ = os.path.split(__file__)
tests_dir = os.path.abspath(os.path.join(home, 'tests')) # 0.3.2 reorg
# Change to tests_dir so that tests can find settings files
os.chdir(tests_dir)
unittest.TextTestRunner(verbosity=verbosity).run(
unittest.defaultTestLoader.discover(tests_dir)
)
os.chdir(cd)