Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
def test_pending_messages(self):
messages = ['HAHAHAH', 'HAHAHAH1', 'HAHAHAH2', 'HAHAHAH3']
for message in messages:
Messages.write_message(message)
pending_messages = MessagesStore.pending_messages()
self.assertEqual(messages, pending_messages)
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)
def _add_message_and_screenshots(response):
response.executionResult.message.extend(MessagesStore.pending_messages())
response.executionResult.screenshots.extend(
ScreenshotsStore.pending_screenshots())
def _add_exception(e, response, continue_on_failure):
if os.getenv('screenshot_on_failure') == 'true':
screenshot = registry.screenshot_provider()()
response.executionResult.screenShot = screenshot
response.executionResult.failureScreenshot = screenshot
response.executionResult.failed = True
message = e.__str__()
if not message:
message = "Exception occurred"
response.executionResult.errorMessage = message
response.executionResult.stackTrace = traceback.format_exc()
response.executionResult.errorType = ProtoExecutionResult.ASSERTION
if continue_on_failure:
response.executionResult.recoverableError = True
response.executionResult.message.extend(MessagesStore.pending_messages())
response.executionResult.screenshots.extend(ScreenshotsStore.pending_screenshots())
def execute_method(params, step, response, is_continue_on_failure=_false):
start = _current_time()
try:
params = _get_args(params, step)
step.impl(*params)
except Exception as e:
_add_exception(e, response, is_continue_on_failure(step.impl, e))
response.executionResult.executionTime = _current_time() - start
response.executionResult.message.extend(MessagesStore.pending_messages())
response.executionResult.screenshots.extend(ScreenshotsStore.pending_screenshots())