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_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])))
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 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 test_clear(self):
ScreenshotsStore.capture()
ScreenshotsStore.clear()
pending_screenshots = ScreenshotsStore.pending_screenshots()
self.assertEqual([], 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_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())