'Run the test case.
This code is basically the same as the standard library, except that when
there is an exception, the --debug (NOTYPO) flag allows us to drop into the
raising function for interactive inspection of the test failure.
Args:
result: The testResult object that we will use.'

def run(self, result=None):

    if (result is None):
        result = self.defaultTestResult()
    result.startTest(self)
    testMethod = getattr(self, self._testMethodName)
    try:
        try:
            self.setUp()
        except unittest.SkipTest:
            result.addSkip(self, sys.exc_info())
            result.stopTest(self)
            return
        except:
            if flags.FLAGS.debug:
                pdb.post_mortem()
            result.addError(self, sys.exc_info())
            raise
        ok = False
        try:
            profile_filename = flags.FLAGS.profile
            if profile_filename:
                cProfile.runctx('testMethod()', globals(), locals(), profile_filename)
            else:
                testMethod()
                self.DoAfterTestCheck()
            ok = True
        except self.failureException:
            if flags.FLAGS.debug:
                pdb.post_mortem()
            result.addFailure(self, sys.exc_info())
        except KeyboardInterrupt:
            raise
        except unittest.SkipTest:
            result.addSkip(self, sys.exc_info())
        except Exception:
            if flags.FLAGS.debug:
                pdb.post_mortem()
            result.addError(self, sys.exc_info())
        try:
            self.tearDown()
        except KeyboardInterrupt:
            raise
        except Exception:
            if flags.FLAGS.debug:
                pdb.post_mortem()
            result.addError(self, sys.exc_info())
            ok = False
        if ok:
            result.addSuccess(self)
    finally:
        result.stopTest(self)
