How to use put_back_line_and_abort method in autotest

Best Python code snippet using autotest_python

version_1.py

Source:version_1.py Github

copy

Full Screen

...126 timestamp_field = '\ttimestamp=%s' % timestamp127 msg = indent + "END ABORT\t%s\t%s%s\t%s"128 return msg % (subdir, testname, timestamp_field, reason)129 @staticmethod130 def put_back_line_and_abort(131 line_buffer, line, indent, subdir, timestamp, reason):132 logging.debug("Unexpected indent regression, aborting")133 line_buffer.put_back(line)134 abort = parser.make_dummy_abort(135 indent, subdir, subdir, timestamp, reason)136 line_buffer.put_back(abort)137 def state_iterator(self, buffer):138 line = None139 new_tests = []140 job_count, boot_count = 0, 0141 min_stack_size = 0142 stack = status_lib.status_stack()143 current_kernel = kernel("", []) # UNKNOWN144 current_status = status_lib.statuses[-1]145 current_reason = None146 started_time_stack = [None]147 subdir_stack = [None]148 running_test = None149 running_reasons = set()150 yield [] # we're ready to start running151 # create a RUNNING SERVER_JOB entry to represent the entire test152 running_job = test.parse_partial_test(self.job, "----", "SERVER_JOB",153 "", current_kernel,154 self.job.started_time)155 new_tests.append(running_job)156 while True:157 # are we finished with parsing?158 if buffer.size() == 0 and self.finished:159 if stack.size() == 0:160 break161 # we have status lines left on the stack,162 # we need to implicitly abort them first163 logging.debug('Unexpected end of job, aborting')164 abort_subdir_stack = list(subdir_stack)165 if self.job.aborted_by:166 reason = "Job aborted by %s" % self.job.aborted_by167 reason += self.job.aborted_on.strftime(168 " at %b %d %H:%M:%S")169 else:170 reason = "Job aborted unexpectedly"171 timestamp = line.optional_fields.get('timestamp')172 for i in reversed(xrange(stack.size())):173 if abort_subdir_stack:174 subdir = abort_subdir_stack.pop()175 else:176 subdir = None177 abort = self.make_dummy_abort(178 i, subdir, subdir, timestamp, reason)179 buffer.put(abort)180 # stop processing once the buffer is empty181 if buffer.size() == 0:182 yield new_tests183 new_tests = []184 continue185 # reinitialize the per-iteration state186 started_time = None187 finished_time = None188 # get the next line189 raw_line = status_lib.clean_raw_line(buffer.get())190 logging.debug('STATUS: %s', raw_line.strip())191 line = status_line.parse_line(raw_line)192 if line is None:193 logging.debug('non-status line, ignoring')194 continue195 # do an initial sanity check of the indentation196 expected_indent = stack.size()197 if line.type == "END":198 expected_indent -= 1199 if line.indent < expected_indent:200 # ABORT the current level if indentation was unexpectedly low201 self.put_back_line_and_abort(202 buffer, raw_line, stack.size() - 1, subdir_stack[-1],203 line.optional_fields.get("timestamp"), line.reason)204 continue205 elif line.indent > expected_indent:206 # ignore the log if the indent was unexpectedly high207 logging.debug("unexpected extra indentation, ignoring")208 continue209 # initial line processing210 if line.type == "START":211 stack.start()212 started_time = line.get_timestamp()213 if (line.testname is None and line.subdir is None and214 not running_test):215 # we just started a client, all tests are relative to here...

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 autotest 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