本文整理汇总了Python中unittest.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"]))
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:27,代码来源:rwdts_pytest.py
示例2: main
def main():
import sys
sys.path.insert(0, "C:/Program Files/Southpaw/Tactic1.9/src/client")
try:
unittest.main()
except SystemExit:
pass
开发者ID:0-T-0,项目名称:TACTIC,代码行数:7,代码来源:maya_test.py
示例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)
开发者ID:Watermelon876,项目名称:dlcoal,代码行数:34,代码来源:testing.py
示例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'})
开发者ID:egon010,项目名称:gstatsd,代码行数:7,代码来源:service_test.py
示例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()
开发者ID:xuanran001,项目名称:xuanran001-webapi-unittest,代码行数:27,代码来源:decorationplan.detail3.py
示例6: run
def run(self):
os.setpgrp()
unittest_args = [sys.argv[0]]
if ARGS.verbose:
unittest_args += ["-v"]
unittest.main(argv=unittest_args)
开发者ID:tupynamba,项目名称:osquery,代码行数:7,代码来源:test_base.py
示例7: run_unittest
def run_unittest(tester):
"""run unittest"""
import unittest
unittest.main(
None, None, [unittest.__file__, tester.test_suite],
testLoader = unittest.TestLoader()
)
开发者ID:vkuznet,项目名称:PyQueryBuilder,代码行数:7,代码来源:disttest.py
示例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]])
开发者ID:slogan621,项目名称:tscharts,代码行数:27,代码来源:category.py
示例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()
开发者ID:JCVI-Cloud,项目名称:galaxy-tools-prok,代码行数:26,代码来源:CheetahWrapper.py
示例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()
开发者ID:bionikspoon,项目名称:playing-with-flask---flasky,代码行数:32,代码来源:test_client.py
示例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()
开发者ID:vrutsky,项目名称:svnfs,代码行数:7,代码来源:test_svnfs.py
示例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()
开发者ID:mellowdistrict,项目名称:luci-py,代码行数:7,代码来源:test_env.py
示例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])
开发者ID:kewllife,项目名称:pyfirebirdsql,代码行数:7,代码来源:setup.py
示例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()
开发者ID:MaximSidorkin,项目名称:sysProj,代码行数:7,代码来源:Check500404_test.py
示例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,)
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:34,代码来源:OTCmd2.py
示例16: main
def main(argv=sys.argv[1:]):
logging.basicConfig(format='TEST %(message)s')
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action='store_true')
parser.add_argument('-w', '--wait', action='store_true',
help="Wait after the tests are done, to inspect the system.")
parser.add_argument('unittest_args', nargs='*')
args = parser.parse_args(argv)
if args.wait: TestRestconf.wait_forever = True
# Set the global logging level
logging.getLogger(__name__).setLevel(logging.DEBUG if args.verbose else logging.ERROR)
try:
# 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__] + args.unittest_args,
testRunner=xmlrunner.XMLTestRunner(
output=os.environ["RIFT_MODULE_TEST"]))
except Exception as exp:
print("Exception thrown", exp)
if TestRestconf.testware is not None:
os.system("stty sane")
TestRestconf.testware.stop_testware()
开发者ID:RIFTIO,项目名称:RIFT.ware,代码行数:28,代码来源:test_restconf_notification.py
示例17: main
def main():
log.basicConfig(
format='%(asctime)s %(name)s %(levelname)s: %(message)s',
datefmt='%m/%d/%Y %I:%M:%S',
level=log.DEBUG)
unittest.main()
开发者ID:jonathansick-shadow,项目名称:dax_metaserv,代码行数:7,代码来源:testSchemaToMeta.py
示例18: main
def main(supported_fmts=[], supported_oses=['linux']):
'''Run tests'''
debug = '-d' in sys.argv
verbosity = 1
if supported_fmts and (imgfmt not in supported_fmts):
notrun('not suitable for this image format: %s' % imgfmt)
if True not in [sys.platform.startswith(x) for x in supported_oses]:
notrun('not suitable for this OS: %s' % sys.platform)
# We need to filter out the time taken from the output so that qemu-iotest
# can reliably diff the results against master output.
import StringIO
if debug:
output = sys.stdout
verbosity = 2
sys.argv.remove('-d')
else:
output = StringIO.StringIO()
class MyTestRunner(unittest.TextTestRunner):
def __init__(self, stream=output, descriptions=True, verbosity=verbosity):
unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity)
# unittest.main() will use sys.exit() so expect a SystemExit exception
try:
unittest.main(testRunner=MyTestRunner)
finally:
if not debug:
sys.stderr.write(re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', output.getvalue()))
开发者ID:Pating,项目名称:qemu-colo,代码行数:31,代码来源:iotests.py
示例19: main
def main():
if len(sys.argv) == 1:
unittest.main()
return
waagent.LoggerInit('/var/log/waagent.log', '/dev/stdout')
waagent.Log("%s started to handle." %(ExtensionShortName))
global hutil
hutil = Util.HandlerUtility(waagent.Log, waagent.Error,
ExtensionShortName)
hutil.do_parse_context('TEST')
global MyPatching
MyPatching = FakePatching(hutil)
if MyPatching == None:
sys.exit(1)
for a in sys.argv[1:]:
if re.match("^([-/]*)(disable)", a):
disable()
elif re.match("^([-/]*)(uninstall)", a):
uninstall()
elif re.match("^([-/]*)(install)", a):
install()
elif re.match("^([-/]*)(enable)", a):
enable()
elif re.match("^([-/]*)(update)", a):
update()
elif re.match("^([-/]*)(download)", a):
download()
elif re.match("^([-/]*)(patch)", a):
patch()
elif re.match("^([-/]*)(oneoff)", a):
oneoff()
开发者ID:MSSedusch,项目名称:azure-linux-extensions,代码行数:35,代码来源:test_handler_1.py
示例20: q1
def q1():
'''
How can I handle errors, like the Zero Division Error,
while testing?
'''
if __name__ == "__main__":
unittest.main()
开发者ID:DZwell,项目名称:sea-c34-python,代码行数:7,代码来源:testing.py
注:本文中的unittest.main函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论