示例#1
0
    def __exit__(self, exc_type, exc_val, exc_tb):
        super(smart_transaction, self).__exit__(exc_type, exc_val, exc_tb)
        self.controller.stopTest(is_transaction=True)
        message = ''

        if exc_type:
            message = str(exc_val)
            exc = exc_type, exc_val, exc_tb
            if isinstance(exc_val, AssertionError):
                status = 'failed'
                self.controller.addFailure(exc, is_transaction=True)
            else:
                status = 'broken'
                tb = get_trace(exc)
                self.controller.addError(exc_type.__name__,
                                         message,
                                         tb,
                                         is_transaction=True)

        else:
            status = 'success'
            self.controller.addSuccess(is_transaction=True)

        put_into_thread_store(status=status, message=message)
        for func in apiritif.get_transaction_handlers()["exit"]:
            func(status, message
                 )  # params for compatibility, remove if bzt > 1.4.1 in cloud

        self.controller.afterTest(is_transaction=True)

        return not self.func_mode  # don't reraise in load mode
示例#2
0
    def __enter__(self):
        self.controller.set_start_time()

        super(smart_transaction, self).__enter__()
        put_into_thread_store(test_case=self.name, test_suite=self.test_suite)
        for func in apiritif.get_transaction_handlers()["enter"]:
            func()
示例#3
0
    def __enter__(self):
        super(smart_transaction, self).__enter__()
        put_into_thread_store(test_case=self.name, test_suite=self.test_suite)
        for func in apiritif.get_transaction_handlers()["enter"]:
            func(self.name, self.test_suite
                 )  # params for compatibility, remove if bzt > 1.4.1 in cloud

        self.controller.startTest()
示例#4
0
    def __exit__(self, exc_type, exc_val, exc_tb):
        super(smart_transaction, self).__exit__(exc_type, exc_val, exc_tb)

        message = ''

        if exc_type:
            message = str(exc_val)
            exc = exc_type, exc_val, exc_tb
            if isinstance(exc_val, AssertionError):
                status = 'failed'
                self.controller.addFailure(exc, is_transaction=True)
            else:
                status = 'broken'
                tb = get_trace(exc)
                self.controller.addError(exc_type.__name__,
                                         message,
                                         tb,
                                         is_transaction=True)

        else:
            status = 'success'
            self.controller.addSuccess(is_transaction=True)

        put_into_thread_store(status=status, message=message)
        for func in apiritif.get_transaction_handlers()["exit"]:
            func()

        self.controller.stopTest(is_transaction=True)

        stage = apiritif.get_stage()
        if stage == "teardown":
            self.func_mode = False
        elif graceful():  # and stage in ("setup", "main")
            raise NormalShutdown("graceful!")

        return not self.func_mode  # don't reraise in load mode
示例#5
0
def add_flow_markers():
    handlers = get_transaction_handlers()
    handlers["enter"].append(_send_start_flow_marker)
    handlers["exit"].append(_send_exit_flow_marker)
    set_transaction_handlers(handlers)
def add_dummy_handlers():
    handlers = get_transaction_handlers()
    handlers["enter"].append(_enter_handler)
    handlers["exit"].append(_exit_handler)
    set_transaction_handlers(handlers)