本文整理汇总了Python中unittest.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main(argv=sys.argv[1:]):
logging.basicConfig(format='->%(asctime)s;%(levelname)s;%(message)s')
top_dir = __file__[:__file__.find('/modules/core/')]
build_dir = os.path.join(top_dir, '.build/modules/core/rwvx/src/core_rwvx-build')
if 'MESSAGE_BROKER_DIR' not in os.environ:
os.environ['MESSAGE_BROKER_DIR'] = os.path.join(build_dir, 'rwmsg/plugins/rwmsgbroker-c')
if 'ROUTER_DIR' not in os.environ:
os.environ['ROUTER_DIR'] = os.path.join(build_dir, 'rwdts/plugins/rwdtsrouter-c')
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--test')
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args(argv)
# Set the global logging level
logging.getLogger().setLevel(logging.DEBUG if args.verbose else logging.INFO)
testname = args.test
logging.info(testname)
# The unittest framework requires a program name, so use the name of this
# file instead (we do not want to have to pass a fake program name to main
# when this is called from the interpreter).
unittest.main(argv=[__file__], defaultTest=testname,
testRunner=xmlrunner.XMLTestRunner(
output=os.environ["RIFT_MODULE_TEST"]))
示例2: main
def main():
import sys
sys.path.insert(0, "C:/Program Files/Southpaw/Tactic1.9/src/client")
try:
unittest.main()
except SystemExit:
pass
示例3: test_main
def test_main():
global _do_pause
o = optparse.OptionParser()
o.add_option("-v", "--verbose", action="store_true",
help="Verbose output")
o.add_option("-q", "--quiet", action="store_true",
help="Minimal output")
o.add_option("-l", "--list_tests", action="store_true")
o.add_option("-p", "--pause", action="store_true")
conf, args = o.parse_args()
if conf.list_tests:
list_tests(1)
return
if conf.pause:
_do_pause = True
# process unittest arguments
argv = [sys.argv[0]]
if conf.verbose:
argv.append("-v")
if conf.quiet:
argv.append("-q")
argv.extend(args)
# run unittest
unittest.main(argv=argv)
示例4: main
def main():
unittest.main()
def test_gauges(self):
pkt = 'foo:50|g'
self.svc._process(pkt, None)
self.assertEquals(self.stats.gauges, {'foo': '50'})
示例5: main
def main():
# create logger
logger = logging.getLogger("decorationplan.detail3")
logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler( sys.__stdout__ ) # Add this
ch.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
# 'application' code
#logger.debug('debug message')
#logger.info('info message')
#logger.warn('warn message')
#logger.error('error message')
#logger.critical('critical message')
unittest.main()
示例6: run
def run(self):
os.setpgrp()
unittest_args = [sys.argv[0]]
if ARGS.verbose:
unittest_args += ["-v"]
unittest.main(argv=unittest_args)
示例7: run_unittest
def run_unittest(tester):
"""run unittest"""
import unittest
unittest.main(
None, None, [unittest.__file__, tester.test_suite],
testLoader = unittest.TestLoader()
)
示例8: main
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "h:p:u:w:")
except getopt.GetoptError as err:
print str(err)
usage()
sys.exit(2)
global host
host = "127.0.0.1"
global port
port = 8000
global username
username = None
global password
password = None
for o, a in opts:
if o == "-h":
host = a
elif o == "-p":
port = int(a)
elif o == "-u":
username = a
elif o == "-w":
password = a
else:
assert False, "unhandled option"
unittest.main(argv=[sys.argv[0]])
示例9: main
def main():
global DELETE, OUTPUT
parser = OptionParser()
parser.add_option("--list", action="store", dest="listTests")
parser.add_option("--nodelete", action="store_true")
parser.add_option("--output", action="store_true")
# The following options are passed to unittest.
parser.add_option("-e", "--explain", action="store_true")
parser.add_option("-v", "--verbose", action="store_true")
parser.add_option("-q", "--quiet", action="store_true")
opts, files = parser.parse_args()
if opts.nodelete:
DELETE = False
if opts.output:
OUTPUT = True
if opts.listTests:
listTests(opts.listTests)
else:
# Eliminate script-specific command-line arguments to prevent
# errors in unittest.
del sys.argv[1:]
for opt in ("explain", "verbose", "quiet"):
if getattr(opts, opt):
sys.argv.append("--" + opt)
sys.argv.extend(files)
unittest.main()
示例10: test_register_and_login
def test_register_and_login(self):
# register a new account
response = self.client.post(url_for('auth.register'), data={
'email': '[email protected]',
'username': 'test',
'password': 'secret',
'password_confirm': 'secret'
})
self.assertEqual(response.status_code, 302)
# login with new account
response = self.client.post(url_for('auth.login'), data={'email': '[email protected]', 'password': 'secret'},
follow_redirects=True)
data = response.get_data(as_text=True)
self.assertRegex(data, 'Hello,\s+test!')
self.assertIn('You have not confirmed your account', data)
# send a confirmation token
user = User.query.filter_by(email='[email protected]').first()
token = user.generate_confirmation_token()
response = self.client.get(url_for('auth.confirm', token=token), follow_redirects=True)
data = response.get_data(as_text=True)
self.assertIn('You have confirmed your account', data)
# log out
response = self.client.get(url_for('auth.logout'), follow_redirects=True)
data = response.get_data(as_text=True)
self.assertIn('You have been logged out', data)
if __name__ == '__main__':
unittest.main()
示例11: run_tests
def run_tests():
if not os.path.isdir(test_repo):
sys.stderr.write("Error: Test repository not found.\n"
"Create test repository first using ./create_test_repo.sh script.\n")
sys.exit(1)
unittest.main()
示例12: main
def main():
if '-v' in sys.argv:
unittest.TestCase.maxDiff = None
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.FATAL)
unittest.main()
示例13: run
def run(self):
'''
Finds all the tests modules in tests/, and runs them.
'''
from firebirdsql import tests
import unittest
unittest.main(tests, argv=sys.argv[:1])
示例14: test_2Not500or404andLoginIsVisible
def test_2Not500or404andLoginIsVisible(self):
assert "500" not in driver.title # проверка на 500/404 ошибку
assert "404" not in driver.title
_ = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'hidden-xs')))
if __name__ == '__main__':
unittest.main()
示例15: iMain
def iMain(lCmdLine):
if '--test' in lCmdLine:
# legacy - unused
sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main()
unittest.main()
return 0
oApp = None
try:
oArgParser = oParseOptions()
oOptions = oArgParser.parse_args(lCmdLine)
sConfigFile = oOptions.sConfigFile
oConfig = oParseConfig(sConfigFile)
oConfig = oMergeConfig(oConfig, oOptions)
oApp = CmdLineApp(oConfig, oOptions.lArgs)
if oOptions.lArgs:
oApp.onecmd_plus_hooks(' '.join(oOptions.lArgs) +'\n')
else:
oApp._cmdloop()
except KeyboardInterrupt:
pass
except Exception as e:
print traceback.format_exc(10)
# always reached
if oApp:
oApp.vAtexit()
l = threading.enumerate()
if len(l) > 1:
print "WARN: Threads still running: %r" % (l,)