How to use _mark_location_as_failed method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

session.py

Source:session.py Github

copy

Full Screen

...76 def _discard_or_fire_event(self, event_class, event):77 discarded = self._discard_pending_event_if_any(event_class)78 if not discarded:79 self.event_manager.fire(event)80 def _mark_location_as_failed(self, location):81 self._failures.add(location)82 def is_successful(self, location=None):83 if location:84 return location not in self._failures85 else:86 return len(self._failures) == 087 def start_step(self, description):88 self._end_step_if_any()89 self.cursor.step = description90 self._hold_event(91 events.StepStartEvent(self.cursor.location, description, _get_thread_id())92 )93 set_step = start_step94 def end_step(self):95 assert self.cursor.step, "There is no started step"96 self._discard_or_fire_event(97 events.StepStartEvent, events.StepEndEvent(self.cursor.location, self.cursor.step, _get_thread_id())98 )99 self.cursor.step = None100 def _end_step_if_any(self):101 if self.cursor.step:102 self.end_step()103 def _log(self, level, content):104 self._flush_pending_events()105 if level == Log.LEVEL_ERROR:106 self._mark_location_as_failed(self.cursor.location)107 self.event_manager.fire(108 events.LogEvent(self.cursor.location, self.cursor.step, _get_thread_id(), level, content)109 )110 def log_debug(self, content):111 return self._log(Log.LEVEL_DEBUG, content)112 def log_info(self, content):113 return self._log(Log.LEVEL_INFO, content)114 def log_warning(self, content):115 return self._log(Log.LEVEL_WARN, content)116 def log_error(self, content):117 return self._log(Log.LEVEL_ERROR, content)118 def log_check(self, description, is_successful, details):119 self._flush_pending_events()120 if is_successful is False:121 self._mark_location_as_failed(self.cursor.location)122 self.event_manager.fire(events.CheckEvent(123 self.cursor.location, self.cursor.step, _get_thread_id(), description, is_successful, details124 ))125 def log_url(self, url, description):126 self._flush_pending_events()127 self.event_manager.fire(128 events.LogUrlEvent(self.cursor.location, self.cursor.step, _get_thread_id(), url, description)129 )130 @contextmanager131 def prepare_attachment(self, filename, description, as_image=False):132 with self._attachment_lock:133 attachment_filename = "%04d_%s" % (self._attachment_count + 1, filename)134 self._attachment_count += 1135 if not os.path.exists(self._attachments_dir):136 os.mkdir(self._attachments_dir)137 yield os.path.join(self._attachments_dir, attachment_filename)138 self._flush_pending_events()139 self.event_manager.fire(events.LogAttachmentEvent(140 self.cursor.location, self.cursor.step, _get_thread_id(),141 "%s/%s" % (_ATTACHMENTS_DIR, attachment_filename), description, as_image142 ))143 def start_test_session(self):144 self.event_manager.fire(events.TestSessionStartEvent(self.report))145 def end_test_session(self):146 self.event_manager.fire(events.TestSessionEndEvent(self.report))147 def start_test_session_setup(self):148 self.cursor = _Cursor(ReportLocation.in_test_session_setup())149 self._hold_event(events.TestSessionSetupStartEvent())150 def end_test_session_setup(self):151 self._end_step_if_any()152 self._discard_or_fire_event(events.TestSessionSetupStartEvent, events.TestSessionSetupEndEvent())153 def start_test_session_teardown(self):154 self.cursor = _Cursor(ReportLocation.in_test_session_teardown())155 self._hold_event(events.TestSessionTeardownStartEvent())156 def end_test_session_teardown(self):157 self._end_step_if_any()158 self._discard_or_fire_event(events.TestSessionTeardownStartEvent, events.TestSessionTeardownEndEvent())159 def start_suite(self, suite):160 self.event_manager.fire(events.SuiteStartEvent(suite))161 def end_suite(self, suite):162 self.event_manager.fire(events.SuiteEndEvent(suite))163 def start_suite_setup(self, suite):164 self.cursor = _Cursor(ReportLocation.in_suite_setup(suite))165 self._hold_event(events.SuiteSetupStartEvent(suite))166 def end_suite_setup(self, suite):167 self._end_step_if_any()168 self._discard_or_fire_event(events.SuiteSetupStartEvent, events.SuiteSetupEndEvent(suite))169 def start_suite_teardown(self, suite):170 self.cursor = _Cursor(ReportLocation.in_suite_teardown(suite))171 self._hold_event(events.SuiteTeardownStartEvent(suite))172 def end_suite_teardown(self, suite):173 self._end_step_if_any()174 self._discard_or_fire_event(events.SuiteTeardownStartEvent, events.SuiteTeardownEndEvent(suite))175 def start_test(self, test):176 self.event_manager.fire(events.TestStartEvent(test))177 self.cursor = _Cursor(ReportLocation.in_test(test))178 def end_test(self, test):179 self._end_step_if_any()180 self.event_manager.fire(events.TestEndEvent(test))181 def skip_test(self, test, reason):182 self.event_manager.fire(events.TestSkippedEvent(test, reason))183 self._mark_location_as_failed(ReportLocation.in_test(test))184 def disable_test(self, test, reason):185 self.event_manager.fire(events.TestDisabledEvent(test, reason))186def _interruptible(wrapped):187 @functools.wraps(wrapped)188 def wrapper(*args, **kwargs):189 if Session.get().aborted:190 raise AbortTest("tests have been manually stopped")191 return wrapped(*args, **kwargs)192 wrapper.__doc__ = wrapped.__doc__193 return wrapper194@_interruptible195def set_step(description, detached=NotImplemented):196 # type: (str, bool) -> None197 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful