本文整理汇总了Python中moztest.results.TestResultCollection类的典型用法代码示例。如果您正苦于以下问题:Python TestResultCollection类的具体用法?Python TestResultCollection怎么用?Python TestResultCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestResultCollection类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
self.marionette = kwargs.pop("marionette")
TestResultCollection.__init__(self, "MarionetteTest")
self.passed = 0
self.testsRun = 0
self.result_modifiers = [] # used by mixins to modify the result
StructuredTestResult.__init__(self, *args, **kwargs)
示例2: __init__
def __init__(self, *args, **kwargs):
self.marionette = kwargs.pop("marionette")
TestResultCollection.__init__(self, "MarionetteTest")
self.passed = 0
self.testsRun = 0
self.result_modifiers = [] # used by mixins to modify the result
pid = kwargs.pop("b2g_pid")
logcat_stdout = kwargs.pop("logcat_stdout")
if pid:
if B2GTestResultMixin not in self.__class__.__bases__:
bases = [b for b in self.__class__.__bases__]
bases.append(B2GTestResultMixin)
self.__class__.__bases__ = tuple(bases)
B2GTestResultMixin.__init__(self, b2g_pid=pid, logcat_stdout=logcat_stdout)
StructuredTestResult.__init__(self, *args, **kwargs)
示例3: main
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)
示例4: Collection
class Collection(unittest.TestCase):
def setUp(self):
c1 = TestContext("host1")
c2 = TestContext("host2")
c3 = TestContext("host2")
c3.os = "B2G"
c4 = TestContext("host1")
t1 = TestResult("t1", context=c1)
t2 = TestResult("t2", context=c2)
t3 = TestResult("t3", context=c3)
t4 = TestResult("t4", context=c4)
self.collection = TestResultCollection("tests")
self.collection.extend([t1, t2, t3, t4])
def test_unique_contexts(self):
self.assertEqual(len(self.collection.contexts), 3)
示例5: main
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)
示例6: post_to_autolog
def post_to_autolog(self, results, name):
from moztest.results import TestContext, TestResult, TestResultCollection
from moztest.output.autolog import AutologOutput
context = TestContext(
testgroup='b2g xpcshell testsuite',
operating_system='android',
arch='emulator',
harness='xpcshell',
hostname=socket.gethostname(),
tree='b2g',
buildtype='opt',
)
collection = TestResultCollection('b2g emulator testsuite')
for result in results:
duration = result.get('time', 0)
if 'skipped' in result:
outcome = 'SKIPPED'
elif 'todo' in result:
outcome = 'KNOWN-FAIL'
elif result['passed']:
outcome = 'PASS'
else:
outcome = 'UNEXPECTED-FAIL'
output = None
if 'failure' in result:
output = result['failure']['text']
t = TestResult(name=result['name'], test_class=name,
time_start=0, context=context)
t.finish(result=outcome, time_end=duration, output=output)
collection.append(t)
collection.time_taken += duration
out = AutologOutput()
out.post(out.make_testgroups(collection))
示例7: setUp
def setUp(self):
c1 = TestContext('host1')
c2 = TestContext('host2')
c3 = TestContext('host2')
c3.os = 'B2G'
c4 = TestContext('host1')
t1 = TestResult('t1', context=c1)
t2 = TestResult('t2', context=c2)
t3 = TestResult('t3', context=c3)
t4 = TestResult('t4', context=c4)
self.collection = TestResultCollection('tests')
self.collection.extend([t1, t2, t3, t4])
示例8: main
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)
示例9: main
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)
示例10: __init__
def __init__(self, *args, **kwargs):
TestResultCollection.__init__(self, 'SessionTest')
self.passed = 0
self.testsRun = 0
self.result_modifiers = [] # used by mixins to modify the result
StructuredTestResult.__init__(self, *args, **kwargs)