def run(self, result=None):

        orig_result = result
        if result is None:
            result = self.defaultTestResult()
            startTestRun = getattr(result, 'startTestRun', None)
            if startTestRun is not None:
                startTestRun()

        self._resultForDoCleanups = result
        result.startTest(self)

        testMethod = getattr(self, self._testMethodName)
        if (getattr(self.__class__, "__unittest_skip__", False) or
                getattr(testMethod, "__unittest_skip__", False)):
            # If the class or method was skipped.
            try:
                skip_why = getattr(self.__class__, '__unittest_skip_why__', '')
                skip_why = (
                    skip_why if skip_why != '' else
                    getattr(testMethod, '__unittest_skip_why__', '')
                )
                self._addSkip(result, skip_why)
            finally:
                result.stopTest(self)
            return

        try:
            success = False
            try:
                deferred = self.setUp()
                if deferred is not None:
                    for x in deferred:
                        yield x
            except SkipTest as e:
                self._addSkip(result, str(e))
            except KeyboardInterrupt:
                raise
            except:
                result.addError(self, sys.exc_info())
            else:
                try:
                    deferred = testMethod()
                    if deferred is not None:
                        for x in deferred:
                            yield x
                except __HOLE__:
                    raise
                except self.failureException:
                    result.addFailure(self, sys.exc_info())
                except _ExpectedFailure as e:
                    addExpectedFailure = getattr(
                        result, 'addExpectedFailure', None)
                    if addExpectedFailure is not None:
                        addExpectedFailure(self, e.exc_info)
                    else:
                        warnings.warn(
                            "TestResult has no addExpectedFailure method, "
                            "reporting as passes", RuntimeWarning
                        )
                        result.addSuccess(self)
                except _UnexpectedSuccess:
                    addUnexpectedSuccess = getattr(
                        result, 'addUnexpectedSuccess', None)
                    if addUnexpectedSuccess is not None:
                        addUnexpectedSuccess(self)
                    else:
                        warnings.warn(
                            "TestResult has no addUnexpectedSuccess method, "
                            "reporting as failures", RuntimeWarning
                        )
                        result.addFailure(self, sys.exc_info())
                except SkipTest as e:
                    self._addSkip(result, str(e))
                except:
                    result.addError(self, sys.exc_info())
                else:
                    success = True

                try:
                    deferred = self.tearDown()
                    if deferred is not None:
                        for x in deferred:
                            yield x
                except KeyboardInterrupt:
                    raise
                except:
                    result.addError(self, sys.exc_info())
                    success = False

            cleanUpSuccess = self.doCleanups()
            success = success and cleanUpSuccess
            if success:
                result.addSuccess(self)
        finally:
            result.stopTest(self)
            if orig_result is None:
                stopTestRun = getattr(result, 'stopTestRun', None)
                if stopTestRun is not None:
                    stopTestRun()
dataset/ETHPy150Open randy3k/UnitTesting/unittesting/core/st3/case.py/DeferrableTestCase.run