author Robert Longson <>
Fri, 01 Jun 2012 16:53:57 -0700
changeset 99658 123be65017577f98542852fc557efa66581100f7
parent 98529 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 105846 2d56621abfee7ceee3ca85cfc74c1c12b65c643c
permissions -rw-r--r--
Bug 758505, Part 3: Avoid unnecessary invalidations on repeated calls to set the same animated value (for SMIL animations of CSS, mapped attrs, and motion). r=dholbert

# 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

from unittest import TextTestRunner as _TestRunner, TestResult as _TestResult
import inspect

'''Helper to make python unit tests report the way that the Mozilla
unit test infrastructure expects tests to report.


import unittest
from mozunit import MozTestRunner

if __name__ == '__main__':

class _MozTestResult(_TestResult):
    def __init__(self, stream, descriptions):
        _TestResult.__init__(self) = stream
        self.descriptions = descriptions

    def getDescription(self, test):
        if self.descriptions:
            return test.shortDescription() or str(test)
            return str(test)

    def addSuccess(self, test):
        _TestResult.addSuccess(self, test)
        filename = inspect.getfile(test.__class__)
        testname = test._testMethodName"TEST-PASS | %s | %s" % (filename, testname))

    def addError(self, test, err):
        _TestResult.addError(self, test, err)
        self.printFail(test, err)

    def addFailure(self, test, err):
        _TestResult.addFailure(self, test, err)

    def printFail(self, test, err):
        exctype, value, tb = err
        # Skip test runner traceback levels
        while tb and self._is_relevant_tb_level(tb):
            tb = tb.tb_next
        if not tb:
        _f, _ln, _t = inspect.getframeinfo(tb)[:3]"TEST-UNEXPECTED-FAIL | %s | line %d, %s: %s" % 
                            (_f, _ln, _t, value.message))

    def printErrorList(self):
        for test, err in self.errors:
  "ERROR: %s" % self.getDescription(test))
  "%s" % err)

class MozTestRunner(_TestRunner):
    def _makeResult(self):
        return _MozTestResult(, self.descriptions)
    def run(self, test):
        result = self._makeResult()
        return result