Bug 1323770 - Moztest should forward correct test result.
Registered callback handlers for tests should receive the correct
test status when the test has been finished, and not always "Error".
This change allows those callbacks to run specific code for individual
test results, eg. only do screenshots for failures.
MozReview-Commit-ID: FfbCRR0Jvjb
--- a/testing/mozbase/moztest/moztest/adapters/unit.py
+++ b/testing/mozbase/moztest/moztest/adapters/unit.py
@@ -129,49 +129,52 @@ class StructuredTestResult(TextTestResul
self.logger.test_end(test.id(),
"ERROR",
message=self._extract_err_message(err),
expected="PASS",
stack=self._extract_stacktrace(err, test),
extra=extra)
def addFailure(self, test, err):
- extra = self.call_callbacks(test, "ERROR")
+ extra = self.call_callbacks(test, "FAIL")
extra.update(self._get_class_method_name(test))
self.logger.test_end(test.id(),
"FAIL",
message=self._extract_err_message(err),
expected="PASS",
stack=self._extract_stacktrace(err, test),
extra=extra)
def addSuccess(self, test):
extra = self._get_class_method_name(test)
- self.logger.test_end(test.id(), "PASS", expected="PASS", extra=extra)
+ self.logger.test_end(test.id(),
+ "PASS",
+ expected="PASS",
+ extra=extra)
def addExpectedFailure(self, test, err):
- extra = self.call_callbacks(test, "ERROR")
+ extra = self.call_callbacks(test, "FAIL")
extra.update(self._get_class_method_name(test))
self.logger.test_end(test.id(),
"FAIL",
message=self._extract_err_message(err),
expected="FAIL",
stack=self._extract_stacktrace(err, test),
extra=extra)
def addUnexpectedSuccess(self, test):
- extra = self.call_callbacks(test, "ERROR")
+ extra = self.call_callbacks(test, "PASS")
extra.update(self._get_class_method_name(test))
self.logger.test_end(test.id(),
"PASS",
expected="FAIL",
extra=extra)
def addSkip(self, test, reason):
- extra = self.call_callbacks(test, "ERROR")
+ extra = self.call_callbacks(test, "SKIP")
extra.update(self._get_class_method_name(test))
self.logger.test_end(test.id(),
"SKIP",
message=reason,
expected="PASS",
extra=extra)
--- a/testing/mozbase/moztest/setup.py
+++ b/testing/mozbase/moztest/setup.py
@@ -1,15 +1,15 @@
# 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/.
from setuptools import setup, find_packages
-PACKAGE_VERSION = '0.7'
+PACKAGE_VERSION = '0.8'
# dependencies
deps = ['mozinfo']
setup(name='moztest',
version=PACKAGE_VERSION,
description="Package for storing and outputting Mozilla test results",
long_description="see http://mozbase.readthedocs.org/",