-
Notifications
You must be signed in to change notification settings - Fork 2
/
try_all_tests.py
36 lines (29 loc) · 993 Bytes
/
try_all_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
'''
run all the tests
'''
import unittest
import argparse
import time
import logging
parser = argparse.ArgumentParser()
parser.add_argument('--pattern', default='test', type=str,
help='pattern base name')
parser.add_argument('--verbosity', default=2, type=int,
help='test verbosity (int)')
def main(pattern, verbosity):
run_time = int(time.time())
logfilename = 'log_' + __file__.split('/')[-1].split('.')[0] \
+ str(run_time) + '.txt'
logging.basicConfig(
filename=logfilename, level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
LOGGER = logging.getLogger(__name__)
LOGGER.info("Starting...")
LOGGER.info(__file__)
pattern = pattern + '*.py'
suite = unittest.TestLoader().discover('./tests/', pattern=pattern)
unittest.TextTestRunner(verbosity=verbosity).run(suite)
if __name__ == '__main__':
args = parser.parse_args()
main(**vars(args))