def _finalize(self, rv):
        """
        Run user-defined `finalize()` and catch exceptions. If an exception
        occurs in the finalize() method (which is supposed to clean up from
        the test and leave the UUT in the same condition as when it was
        entered) then alter the return value to abort() which will abort the
        suite. Invokes the debugger if the debug flag is set.
        """
        try:
            self.finalize(rv)
        except:
            ex, val, tb = sys.exc_info()
            self.diagnostic("%s (%s)" % (ex, val))
            if self._debug:
                debugger.post_mortem(tb, ex, val)
            self.abort("Test finalize failed!")
        return rv

    # utility methods - methods that are common to nearly all tests.
dataset/ETHPy150Open kdart/pycopia/QA/pycopia/QA/core.py/Test._finalize/original