Ejemplo n.º 1
0
def _execute_before_step_hook(request, response, _socket):
    MessagesStore.clear()
    execution_info = create_execution_context_from(
        request.stepExecutionStartingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(
        execution_info.specification.tags)
    run_hook(request, response, registry.before_step(tags), execution_info)
Ejemplo n.º 2
0
 def test_clear(self):
     messages = ['HAHAHAH', 'HAHAHAH1', 'HAHAHAH2', 'HAHAHAH3']
     for message in messages:
         Messages.write_message(message)
     MessagesStore.clear()
     pending_messages = MessagesStore.pending_messages()
     self.assertEqual([], pending_messages)
Ejemplo n.º 3
0
def _execute_after_step_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.stepExecutionEndingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + list(
        execution_info.specification.tags)
    run_hook(request, response, registry.after_step(tags), execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
Ejemplo n.º 4
0
def _execute_after_suite_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.executionEndingRequest.currentExecutionInfo)
    run_hook(request, response, registry.after_suite(), execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
    response.executionStatusResponse.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())
Ejemplo n.º 5
0
def _execute_before_spec_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.specExecutionStartingRequest.currentExecutionInfo)
    run_hook(request, response,
             registry.before_spec(execution_info.specification.tags),
             execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
Ejemplo n.º 6
0
    def test_pending_messages_gives_only_those_messages_which_are_not_reported(self):
        messages = ['HAHAHAH', 'HAHAHAH1', 'HAHAHAH2', 'HAHAHAH3']
        for message in messages:
            Messages.write_message(message)
        pending_messages = MessagesStore.pending_messages()
        self.assertEqual(messages, pending_messages)

        pending_messages = MessagesStore.pending_messages()

        self.assertEqual([], pending_messages)

        messages = ['HAHAHAH', 'HAHAHAH1']
        for message in messages:
            Messages.write_message(message)

        pending_messages = MessagesStore.pending_messages()

        self.assertEqual(messages, pending_messages)
Ejemplo n.º 7
0
def _execute_before_scenario_hook(request, response, _socket):
    execution_info = create_execution_context_from(
        request.scenarioExecutionStartingRequest.currentExecutionInfo)
    tags = list(execution_info.scenario.tags) + \
        list(execution_info.specification.tags)
    run_hook(request, response, registry.before_scenario(tags), execution_info)
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
    response.executionStatusResponse.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())
Ejemplo n.º 8
0
def execute_method(params, func, response, is_continue_on_failure=_false):
    start = _current_time()
    try:
        func(*params)
    except Exception as e:
        _add_exception(e, response, is_continue_on_failure(func, e))
    response.executionStatusResponse.executionResult.executionTime = _current_time(
    ) - start
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
    response.executionStatusResponse.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())
Ejemplo n.º 9
0
def _execute_before_suite_hook(request, response, _socket, clear=True):
    if clear:
        registry.clear()
        load_impls(get_step_impl_dir())
    if environ.get('DEBUGGING'):
        ptvsd.enable_attach('', address=('127.0.0.1', int(environ.get('DEBUG_PORT'))))
        logging.info(ATTACH_DEBUGGER_EVENT)
        t = Timer(int(environ.get("debugger_wait_time", 30)), handle_detached)
        t.start()
        ptvsd.wait_for_attach()
        t.cancel()

    execution_info = create_execution_context_from(request.executionStartingRequest.currentExecutionInfo)
    run_hook(request, response, registry.before_suite(), execution_info)
    response.executionStatusResponse.executionResult.message.extend(MessagesStore.pending_messages())
Ejemplo n.º 10
0
def _add_exception(e, response, continue_on_failure):
    if os.getenv('screenshot_on_failure') == 'true':
        screenshot = registry.screenshot_provider()()
        response.executionStatusResponse.executionResult.screenShot = screenshot
        response.executionStatusResponse.executionResult.failureScreenshot = screenshot
    response.executionStatusResponse.executionResult.failed = True
    message = e.__str__()
    if not message:
        message = "Exception occurred"
    response.executionStatusResponse.executionResult.errorMessage = message
    response.executionStatusResponse.executionResult.stackTrace = traceback.format_exc(
    )
    response.executionStatusResponse.executionResult.errorType = ProtoExecutionResult.ASSERTION
    if continue_on_failure:
        response.executionStatusResponse.executionResult.recoverableError = True
    response.executionStatusResponse.executionResult.message.extend(
        MessagesStore.pending_messages())
    response.executionStatusResponse.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())
Ejemplo n.º 11
0
 def write_message(message):
     MessagesStore.write_message(message)
Ejemplo n.º 12
0
def _add_message_and_screenshots(response):
    response.executionResult.message.extend(MessagesStore.pending_messages())
    response.executionResult.screenshots.extend(
        ScreenshotsStore.pending_screenshots())