コード例 #1
0
ファイル: CoreTestBase.py プロジェクト: zhengge2017/coala
    def execute_run(self, bears, executor=None):
        """
        Executes a coala run and returns the results.

        This function has multiple ways to provide a different executor than
        the default one (topmost item has highest precedence):

        - Pass it via the ``executor`` parameter.
        - Assign an executor class and the according instantiation arguments to
          ``self.executor`` during ``setUp()``.

        :param bears:
            The bears to run.
        :param executor:
            The executor to run bears on.
        :return:
            A list of results.
        """
        if executor is None:
            executor = getattr(self, 'executor', None)
            if executor is not None:
                cls, args, kwargs = self.executor
                executor = cls(*args, **kwargs)

        results = []

        def capture_results(result):
            results.append(result)

        run(bears, capture_results, executor)

        return results
コード例 #2
0
ファイル: CoreTestBase.py プロジェクト: Anmolbansal1/coala
    def execute_run(self, bears, cache=None, executor=None):
        """
        Executes a coala run and returns the results.

        This function has multiple ways to provide a different executor than
        the default one (topmost item has highest precedence):

        - Pass it via the ``executor`` parameter.
        - Assign an executor class and the according instantiation arguments to
          ``self.executor`` during ``setUp()``.

        :param bears:
            The bears to run.
        :param cache:
            A cache the bears can use to speed up runs. If ``None``, no cache
            will be used.
        :param executor:
            The executor to run bears on.
        :return:
            A list of results.
        """
        if executor is None:
            executor = getattr(self, 'executor', None)
            if executor is not None:
                cls, args, kwargs = self.executor
                executor = cls(*args, **kwargs)

        results = []

        def capture_results(result):
            results.append(result)

        run(bears, capture_results, cache, executor)

        return results
コード例 #3
0
    def get_run_results(bears, executor=None):
        results = []

        def on_result(result):
            results.append(result)

        run(bears, on_result, executor)

        return results
コード例 #4
0
ファイル: CoreTest.py プロジェクト: zachsnyder1/coala
    def execute_run(bears):
        results = []

        def on_result(result):
            results.append(result)

        run(bears, on_result)

        return results
コード例 #5
0
ファイル: CoreTest.py プロジェクト: vrishank97/coala
    def test_run_result_handler_exception(self):
        # Test exception in result handler. The core needs to retry to invoke
        # the handler and then exit correctly if no more results and bears are
        # left.
        bear = MultiTaskBear(self.section1, self.filedict1, tasks_count=10)

        on_result = unittest.mock.Mock(side_effect=ValueError)

        with self.assertLogs(logging.getLogger()) as cm:
            run({bear}, on_result)

        on_result.assert_has_calls([unittest.mock.call(i) for i in range(10)],
                                   any_order=True)

        self.assertEqual(len(cm.output), 10)
        for i in range(10):
            self.assertTrue(cm.output[i].startswith(
                'ERROR:root:An exception was thrown during result-handling.'))