def finalize(self):
        """Perform any finalization needed by the test runner.
        Sends runner end messages to report. Finalizes report.
        """
        cf = self.config
        rpt = cf.report
        rpt.add_message("RUNNERENDTIME", timelib.now(), 0)
        rpt.finalize()
        # force close of report and logfile between objects. these are
        # `property` objects and deleting them makes them close and clears the
        # cache.
        del rpt
        del cf.report
        del cf.logfile
        del cf.UI
        del cf.environment
        if cf.has_key("resultsdir"):
            for fname in cf.reportfilenames:
                if not fname.startswith("<"): # a real file, not builtin stdio
                    if os.path.isfile(fname):
                        shutil.move(fname, cf.resultsdir)
            for suffix in ("", ".1", ".2", ".3", ".4", ".5"): # log may have rotated
                fname = cf.logfilename + suffix
                if os.path.isfile(fname):
                    if os.path.getsize(fname) > 0:
                        shutil.move(fname, cf.resultsdir)
                    else:
                        os.unlink(fname)
            # If resultsdir ends up empty, remove it.
            if not os.listdir(cf.resultsdir): # TODO, stat this instead
                os.rmdir(cf.resultsdir)
dataset/ETHPy150Open kdart/pycopia/QA/pycopia/QA/testrunner.py/TestRunner.finalize/original