forked from thiagosm/PyNFe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
30 lines (22 loc) · 878 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
import sys, doctest, os, glob
from getopt import gnu_getopt as getopt
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, CUR_DIR)
if __name__ == '__main__':
run_level = None
optlist, args = getopt(sys.argv[1:], "l:", ['--level='])
for opt, arg in optlist:
if opt in ("-l", "--list"):
run_level = arg.zfill(2)
# Test each package
if run_level is None:
search_path = '%s/*.txt' % os.path.join(CUR_DIR, 'tests')
else: search_path = '%s/%s-*.txt' % \
(os.path.join(CUR_DIR, 'tests'), run_level)
test_files = glob.glob(search_path)
test_files = map(lambda i: i[len(CUR_DIR)+1:], test_files)
# Run the tests
for fname in test_files:
print 'Running "%s"...'%(os.path.splitext(os.path.split(fname)[-1])[0])
doctest.testfile(fname)
print 'Finished!'