Пример #1
0
    def check_excep(expr_val_list):
        """
        Check if any exception happened when computing
        :class:`exekall.engine.ExprVal` in the given list.

        If an exception is detected, a :class:`TestResult` is raised with
        :attr:`TestResultStatus.FAILED` status.
        """
        failed_expr_val_list = [
            failed_expr_val
            for expr_val in expr_val_list
            for failed_expr_val in expr_val.get_excep()
        ]

        if failed_expr_val_list:
            def format_error(expr_val):
                return '{}:\n{}'.format(
                    expr_val.get_id(qual=False),
                    indent(utils.format_exception(expr_val.excep))
                )
            raise TestResult(
                TestResultStatus.FAILED,
                'Exceptions during expression execution:\n{}\n'.format(
                    '\n\n'.join(
                        indent(format_error(failed_expr_val))
                        for failed_expr_val in failed_expr_val_list
                    )
                ),
                [expr_val.expr for expr_val in expr_val_list]
            )
Пример #2
0
    def __init__(self, expr_data: engine.ExprData):
        self.expr_list = self.make_expressions(
            set(self.CALLABLES),
            goal_type=self.GOAL_TYPE,
            tags_getter=self.get_tags,
            non_reusable_type_set=self.NON_REUSABLE_TYPES,
        )

        self.artifact_dir = expr_data['artifact_dir']

        print('Tested expressions:')
        for expr in self.expr_list:
            print(indent(expr.format_structure()))

        self.dump_expr_layout()
Пример #3
0
        def wrapper(self, *args, **kwargs):
            try:
                f(self, *args, **kwargs)
            except TestResult as e:
                result = e
            except AssertionError as e:
                result = TestResult(
                    TestResultStatus.FAILED, 'failed assertion: {}\n{}'.format(
                        e, indent(utils.format_exception(e))), [])
            else:
                result = TestResult(TestResultStatus.PASSED)

            if result.expr_list is None:
                result.expr_list = self.expr_list

            return result
Пример #4
0
 def format_error(expr_val):
     return '{}:\n{}'.format(
         expr_val.get_id(qual=False),
         indent(utils.format_exception(expr_val.excep))
     )