-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.py
43 lines (38 loc) · 1.12 KB
/
test.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
43
# vim:ai:et:ff=unix:fileencoding=utf-8:sw=4:ts=4:
from __future__ import (absolute_import, print_function, unicode_literals)
import argparse
import logging
import logging.config
import sys
try:
import unittest2 as unittest
except ImportError:
import unittest
def _main(argv):
parser = argparse.ArgumentParser(prog='conveyor-test')
parser.add_argument(
'--logging',
default=None,
metavar='FILE')
parser.add_argument(
'--xml',
action='store_true',
default=False)
parser.add_argument('args', nargs=argparse.REMAINDER)
args = parser.parse_args(argv[1:])
testrunner = None
if None is not args.logging:
logging.config.fileConfig(args.logging)
if args.xml:
import xmlrunner
testrunner = xmlrunner.XMLTestRunner(output=str('obj/'))
if 0 != len(args.args) and '--' == args.args[0]:
args.args = args.args[1:]
sys.argv[1:] = args.args
code = unittest.main(module=None, testRunner=testrunner)
return code
if '__main__' == __name__:
code = _main(sys.argv)
if None is code:
code = 0
sys.exit(code)