You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
878 B
30 lines
878 B
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!'
|
|
|