-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·42 lines (31 loc) · 980 Bytes
/
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
#!/usr/bin/python3
import os.path
import unittest
import argparse
import logging
try:
import coverage
except ImportError:
coverage = None
def parse_opts():
parser = argparse.ArgumentParser(description='bridge tests')
parser.add_argument('-c', '--coverage', help='Run coverage too', action='store_true')
opts = parser.parse_args()
return opts
def main():
opts = parse_opts()
this_dir = os.path.dirname(__file__)
test_dir = os.path.join(os.path.abspath(this_dir), 'tests')
root = logging.getLogger()
root.setLevel(logging.CRITICAL)
if opts.coverage and coverage:
cov = coverage.coverage(source=['bridge', 'insteon_protocol', 'upb'])
cov.start()
suite = unittest.defaultTestLoader.discover(test_dir, pattern="*test.py")
unittest.TextTestRunner(verbosity=2).run(suite)
if opts.coverage and coverage:
cov.stop()
cov.save()
cov.report()
if __name__ == "__main__":
main()