зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1003401 - Mozbase unit test logs should include test name in failures. r=dminor
This commit is contained in:
Родитель
38b0b1f449
Коммит
d889f07732
|
@ -23,6 +23,23 @@ from moztest.results import TestResultCollection
|
||||||
|
|
||||||
here = os.path.dirname(os.path.abspath(__file__))
|
here = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class TBPLTextTestResult(unittest.TextTestResult):
|
||||||
|
"""
|
||||||
|
Format the failure outputs according to TBPL. See:
|
||||||
|
https://wiki.mozilla.org/Sheriffing/Job_Visibility_Policy#6.29_Outputs_failures_in_a_TBPL-starrable_format
|
||||||
|
"""
|
||||||
|
|
||||||
|
def addFailure(self, test, err):
|
||||||
|
super(unittest.TextTestResult, self).addFailure(test, err)
|
||||||
|
self.stream.writeln()
|
||||||
|
self.stream.writeln('TEST-UNEXPECTED-FAIL | %s | %s' % (test.id(), err[1]))
|
||||||
|
|
||||||
|
def addUnexpectedSuccess(self, test):
|
||||||
|
super(unittest.TextTestResult, self).addUnexpectedSuccess(test)
|
||||||
|
self.stream.writeln()
|
||||||
|
self.stream.writeln('TEST-UNEXPECTED-PASS | %s | Unexpected pass' % test.id())
|
||||||
|
|
||||||
def unittests(path):
|
def unittests(path):
|
||||||
"""return the unittests in a .py file"""
|
"""return the unittests in a .py file"""
|
||||||
|
|
||||||
|
@ -85,7 +102,8 @@ def main(args=sys.argv[1:]):
|
||||||
|
|
||||||
# run the tests
|
# run the tests
|
||||||
suite = unittest.TestSuite(unittestlist)
|
suite = unittest.TestSuite(unittestlist)
|
||||||
runner = unittest.TextTestRunner(verbosity=2) # default=1 does not show success of unittests
|
runner = unittest.TextTestRunner(verbosity=2, # default=1 does not show success of unittests
|
||||||
|
resultclass=TBPLTextTestResult)
|
||||||
unittest_results = runner.run(suite)
|
unittest_results = runner.run(suite)
|
||||||
results = TestResultCollection.from_unittest_results(None, unittest_results)
|
results = TestResultCollection.from_unittest_results(None, unittest_results)
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче