本文整理汇总了Python中moztest.results.TestResultCollection.from_unittest_results方法的典型用法代码示例。如果您正苦于以下问题:Python TestResultCollection.from_unittest_results方法的具体用法?Python TestResultCollection.from_unittest_results怎么用?Python TestResultCollection.from_unittest_results使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moztest.results.TestResultCollection
的用法示例。
在下文中一共展示了TestResultCollection.from_unittest_results方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from moztest.results import TestResultCollection [as 别名]
# 或者: from moztest.results.TestResultCollection import from_unittest_results [as 别名]
def main(args=sys.argv[1:]):
# read the manifest
if args:
manifests = args
else:
manifests = [os.path.join(here, 'test-manifest.ini')]
missing = []
for manifest in manifests:
# ensure manifests exist
if not os.path.exists(manifest):
missing.append(manifest)
assert not missing, 'manifest%s not found: %s' % ((len(manifests) == 1 and '' or 's'), ', '.join(missing))
manifest = manifestparser.TestManifest(manifests=manifests)
# gather the tests
tests = manifest.active_tests()
unittestlist = []
for test in tests:
unittestlist.extend(unittests(test['path']))
# run the tests
suite = unittest.TestSuite(unittestlist)
runner = unittest.TextTestRunner(verbosity=2) # default=1 does not show success of unittests
unittest_results = runner.run(suite)
results = TestResultCollection.from_unittest_results(None, unittest_results)
# exit according to results
sys.exit(1 if results.num_failures else 0)
示例2: main
# 需要导入模块: from moztest.results import TestResultCollection [as 别名]
# 或者: from moztest.results.TestResultCollection import from_unittest_results [as 别名]
def main(args=sys.argv[1:]):
# parse command line options
usage = '%prog [options] manifest.ini <manifest.ini> <...>'
parser = optparse.OptionParser(usage=usage, description=__doc__)
parser.add_option('-b', "--binary",
dest="binary", help="Binary path",
metavar=None, default=None)
parser.add_option('--list', dest='list_tests',
action='store_true', default=False,
help="list paths of tests to be run")
mozlog.commandline.add_logging_group(parser)
options, args = parser.parse_args(args)
logger = mozlog.commandline.setup_logging("mozbase", options,
{"tbpl": sys.stdout})
# read the manifest
if args:
manifests = args
else:
manifests = [os.path.join(here, 'test-manifest.ini')]
missing = []
for manifest in manifests:
# ensure manifests exist
if not os.path.exists(manifest):
missing.append(manifest)
assert not missing, 'manifest(s) not found: %s' % ', '.join(missing)
manifest = manifestparser.TestManifest(manifests=manifests)
if options.binary:
# A specified binary should override the environment variable
os.environ['BROWSER_PATH'] = options.binary
# gather the tests
tests = manifest.active_tests(disabled=False, **mozinfo.info)
tests = [test['path'] for test in tests]
logger.suite_start(tests)
if options.list_tests:
# print test paths
print '\n'.join(tests)
sys.exit(0)
# create unittests
unittestlist = []
for test in tests:
unittestlist.extend(unittests(test))
# run the tests
suite = unittest.TestSuite(unittestlist)
runner = StructuredTestRunner(logger=logger)
unittest_results = runner.run(suite)
results = TestResultCollection.from_unittest_results(None, unittest_results)
logger.suite_end()
# exit according to results
sys.exit(1 if results.num_failures else 0)
示例3: main
# 需要导入模块: from moztest.results import TestResultCollection [as 别名]
# 或者: from moztest.results.TestResultCollection import from_unittest_results [as 别名]
def main(args=sys.argv[1:]):
# parse command line options
usage = '%prog [options] manifest.ini <manifest.ini> <...>'
parser = optparse.OptionParser(usage=usage, description=__doc__)
parser.add_option('--list', dest='list_tests',
action='store_true', default=False,
help="list paths of tests to be run")
options, args = parser.parse_args(args)
# read the manifest
if args:
manifests = args
else:
manifests = [os.path.join(here, 'test-manifest.ini')]
missing = []
for manifest in manifests:
# ensure manifests exist
if not os.path.exists(manifest):
missing.append(manifest)
assert not missing, 'manifest(s) not found: %s' % ', '.join(missing)
manifest = manifestparser.TestManifest(manifests=manifests)
# gather the tests
tests = manifest.active_tests(disabled=False, **mozinfo.info)
tests = [test['path'] for test in tests]
if options.list_tests:
# print test paths
print '\n'.join(tests)
sys.exit(0)
# create unittests
unittestlist = []
for test in tests:
unittestlist.extend(unittests(test))
# run the tests
suite = unittest.TestSuite(unittestlist)
runner = unittest.TextTestRunner(verbosity=2) # default=1 does not show success of unittests
unittest_results = runner.run(suite)
results = TestResultCollection.from_unittest_results(None, unittest_results)
# exit according to results
sys.exit(1 if results.num_failures else 0)
示例4: main
# 需要导入模块: from moztest.results import TestResultCollection [as 别名]
# 或者: from moztest.results.TestResultCollection import from_unittest_results [as 别名]
def main(args=sys.argv[1:]):
# read the manifest
if args:
manifests = args
else:
manifests = [os.path.join(here, 'manifest.ini')]
missing = []
for manifest_file in manifests:
# ensure manifests exist
if not os.path.exists(manifest_file):
missing.append(manifest_file)
assert not missing, 'manifest%s not found: %s' % (
(len(manifests) == 1 and '' or 's'), ', '.join(missing))
manifest = TestManifest(manifests=manifests)
unittest_results = test_all(manifest)
results = TestResultCollection.from_unittest_results(
None, unittest_results)
# exit according to results
sys.exit(1 if results.num_failures else 0)