コード例 #1
0
    def startTestRun(self):
        """Called once before any tests are executed."""
        super(Result, self).startTestRun()

        core_log.info("Test run has started")

        for result_handler in self.result_handlers:
            result_handler.start_test_run()
コード例 #2
0
    def stopTestRun(self):
        """Called once after all tests are executed."""
        super(Result, self).stopTestRun()

        core_log.info("Test run has finished")

        for result_handler in self.result_handlers:
            result_handler.stop_test_run()
コード例 #3
0
    def startComposite(self, test):
        """Called when the given TestSuite is about to be run.

        This method, unlike 'startTest', does not call unittest TestResult's
        'startTest', in order to avoid wrong test counting and treating
        TestSuites as the actual tests.

        Args:
            test (rotest.core.suite.TestSuite): test item instance.
        """
        core_log.info("Test %r has started running", test.data)
        test.start()

        for result_handler in self.result_handlers:
            result_handler.start_composite(test)
コード例 #4
0
    def restart_worker(self, worker, reason):
        """Terminate the given worker and start a replacement worker.

        Note:
            Terminated tests will result in 'Error', and won't run again.

        Args:
            worker (WorkerProcess): terminated worker's process.
            reason (str): the reason for the reset.
        """
        core_log.info("Worker %r is dead. Restarting", worker)

        # Check if the worker was restarted before a test started
        if worker.test is not None:
            self.result.addError(worker.test, (RuntimeError, reason, None))
            self.result.stopComposite(worker.test.parent)

        worker_to_terminate = self.workers_pool.pop(worker.pid)
        worker_to_terminate.terminate()

        # Waiting for the old process to die before creating a new one
        time.sleep(self.PROCESS_DEATH_TIMEOUT)

        self.initialize_worker()