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())
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()) response.executionStatusResponse.executionResult.screenshots.extend( ScreenshotsStore.pending_screenshots())
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()) response.executionStatusResponse.executionResult.screenshots.extend( ScreenshotsStore.pending_screenshots())
def test_pending_screenshots_gives_only_those_screenshots_which_are_not_collected(self): ScreenshotsStore.capture() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(['foo'], pending_screenshots) pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual([], pending_screenshots) ScreenshotsStore.capture() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(['foo'], pending_screenshots)
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())
def test_pending_screenshots_gives_only_those_screenshots_which_are_not_collected(self): ScreenshotsStore.capture() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(1, len(pending_screenshots)) screenshot_file = pending_screenshots[0] pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(0, len(pending_screenshots)) ScreenshotsStore.capture() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(1, len(pending_screenshots)) self.assertNotEqual(screenshot_file, pending_screenshots[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())
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')))) print(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()) response.executionStatusResponse.executionResult.screenshots.extend( ScreenshotsStore.pending_screenshots())
def test_capture_shoould_vefify_screenshot_file_for_file_based_custom_screenshot(self): first_screenshot = os.path.join( os.getenv("gauge_screenshots_dir"), "screenshot{0}.png".format(uuid1())) second_screenshot = os.path.join( os.getenv("gauge_screenshots_dir"), "screenshot{0}.png".format(uuid1())) def returns_abs_path(): return first_screenshot def returns_base_ath(): return os.path.basename(second_screenshot) registry.set_screenshot_provider(returns_abs_path, True) ScreenshotsStore.capture() self.assertEqual([os.path.basename(first_screenshot)], ScreenshotsStore.pending_screenshots()) registry.set_screenshot_provider(returns_base_ath, True) ScreenshotsStore.capture() self.assertEqual([os.path.basename(second_screenshot)], ScreenshotsStore.pending_screenshots())
def capture_screenshot(): ScreenshotsStore.capture()
def test_clear(self): ScreenshotsStore.capture() ScreenshotsStore.clear() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual([], pending_screenshots)
def test_pending_screenshots(self): ScreenshotsStore.capture() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(['foo'], pending_screenshots)
def test_pending_screenshots(self): ScreenshotsStore.capture() pending_screenshots = ScreenshotsStore.pending_screenshots() self.assertEqual(1, len(pending_screenshots)) self.assertTrue(os.path.exists(os.path.join( os.getenv("gauge_screenshots_dir"), pending_screenshots[0])))
def _add_message_and_screenshots(response): response.executionResult.message.extend(MessagesStore.pending_messages()) response.executionResult.screenshots.extend( ScreenshotsStore.pending_screenshots())