# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
class TestRunner(object): def __init__(self):
self.logger = get_default_logger(component="TestRunner")
def gather_tests(self): for item in six.itervalues(globals()): if isinstance(item, types.FunctionType) and item.__name__.startswith( "test_"
): yield item.__name__, item
def run(self):
tests = list(self.gather_tests())
self.logger.suite_start(tests=[name for name, func in tests])
self.logger.info("Running tests") for name, func in tests:
self.run_test(name, func)
self.logger.suite_end()
def run_test(self, name, func):
self.logger.test_start(name)
status = None
message = None
expected = func._expected if hasattr(func, "_expected") else"PASS" try:
func() except TestAssertion as e:
status = "FAIL"
message = str(e) except Exception:
status = "ERROR"
message = traceback.format_exc() else:
status = "PASS"
self.logger.test_end(name, status=status, expected=expected, message=message)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.