Python unittest._TextTestResult() Examples

The following are 6 code examples of unittest._TextTestResult(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module unittest , or try the search function .
Example #1
Source File: taprunner.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def addSuccess(self, test):
        super(TextTestResult, self).addSuccess(test)
        self._process(test, "ok") 
Example #2
Source File: taprunner.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def addFailure(self, test, err):
        super(TextTestResult, self).addFailure(test, err)
        self._process(test, "not ok", "FAIL")
        # [ ] add structured data about assertion 
Example #3
Source File: taprunner.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def addError(self, test, err):
        super(TextTestResult, self).addError(test, err)
        self._process(test, "not ok", "ERROR")
        # [ ] add structured data about exception 
Example #4
Source File: taprunner.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def addSkip(self, test, reason):
        super(TextTestResult, self).addSkip(test, reason)
        self._process(test, "ok", directive=("  # SKIP  %s" % reason)) 
Example #5
Source File: taprunner.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def addExpectedFailure(self, test, err):
        super(TextTestResult, self).addExpectedFailure(test, err)
        self._process(test, "not ok", directive=("  # TODO")) 
Example #6
Source File: run_tests.py    From python-sdk with MIT License 5 votes vote down vote up
def run_test_suite():
    def mark_failed():
        global failed
        failed = True

    class _TrackingTextTestResult(unittest._TextTestResult):
        def addError(self, test, err):
            unittest._TextTestResult.addError(self, test, err)
            mark_failed()

        def addFailure(self, test, err):
            unittest._TextTestResult.addFailure(self, test, err)
            mark_failed()

    class TrackingTextTestRunner(unittest.TextTestRunner):
        def _makeResult(self):
            return _TrackingTextTestResult(
                self.stream, self.descriptions, self.verbosity)

    load_env_file(os.path.abspath(os.getcwd()) + os.sep + "environment.env")
    original_cwd = os.path.abspath(os.getcwd())
    os.chdir('.%stests%s' % (os.sep, os.sep))
    suite = unittest.defaultTestLoader.discover('.', pattern="*.py")
    runner = TrackingTextTestRunner(verbosity=2)
    runner.run(suite)
    os.chdir(original_cwd)

    return failed