How to use _append_return_code_as_test method in stestr

Best Python code snippet using stestr_python

run.py

Source:run.py Github

copy

Full Screen

...50 self.proc = process51 self.done = False52 self.source = self.proc.stdout53 self.lastoutput = LINEFEED54 def _append_return_code_as_test(self):55 if self.done is True:56 return57 self.source = BytesIO()58 returncode = self.proc.wait()59 if returncode != 0:60 if self.lastoutput != LINEFEED:61 # Subunit V1 is line orientated, it has to start on a fresh62 # line. V2 needs to start on any fresh utf8 character border63 # - which is not guaranteed in an arbitrary stream endpoint, so64 # injecting a \n gives us such a guarantee.65 self.source.write(_b('\n'))66 if v2_avail:67 stream = subunit.StreamResultToBytes(self.source)68 stream.status(test_id='process-returncode', test_status='fail',69 file_name='traceback', mime_type='text/plain;charset=utf8',70 file_bytes=('returncode %d' % returncode).encode('utf8'))71 else:72 self.source.write(_b('test: process-returncode\n'73 'failure: process-returncode [\n'74 ' returncode %d\n'75 ']\n' % returncode))76 self.source.seek(0)77 self.done = True78 def read(self, count=-1):79 if count == 0:80 return _b('')81 result = self.source.read(count)82 if result:83 self.lastoutput = result[-1]84 return result85 self._append_return_code_as_test()86 return self.source.read(count)87 def readline(self):88 result = self.source.readline()89 if result:90 self.lastoutput = result[-1]91 return result92 self._append_return_code_as_test()93 return self.source.readline()94 def readlines(self):95 result = self.source.readlines()96 if result:97 self.lastoutput = result[-1][-1]98 self._append_return_code_as_test()99 result.extend(self.source.readlines())100 return result101class run(Command):102 __doc__ = """Run the tests for a project and load them into testrepository.103 """ + testrconf_help104 options = [105 optparse.Option("--failing", action="store_true",106 default=False, help="Run only tests known to be failing."),107 optparse.Option("--parallel", action="store_true",108 default=False, help="Run tests in parallel processes."),109 optparse.Option("--concurrency", action="store", type="int", default=0,110 help="How many processes to use. The default (0) autodetects your CPU count."),111 optparse.Option("--load-list", default=None,112 help="Only run tests listed in the named file."),...

Full Screen

Full Screen

output.py

Source:output.py Github

copy

Full Screen

...148 self.source = self.proc.stdout149 self.lastoutput = bytes((b'\n')[0])150 def __del__(self):151 self.proc.wait()152 def _append_return_code_as_test(self):153 if self.done is True:154 return155 self.source = io.BytesIO()156 returncode = self.proc.wait()157 if returncode != 0:158 if self.lastoutput != bytes((b'\n')[0]):159 # Subunit V1 is line orientated, it has to start on a fresh160 # line. V2 needs to start on any fresh utf8 character border161 # - which is not guaranteed in an arbitrary stream endpoint, so162 # injecting a \n gives us such a guarantee.163 self.source.write(bytes('\n'))164 stream = subunit.StreamResultToBytes(self.source)165 stream.status(test_id='process-returncode', test_status='fail',166 file_name='traceback',167 mime_type='text/plain;charset=utf8',168 file_bytes=(169 'returncode %d' % returncode).encode('utf8'))170 self.source.seek(0)171 self.done = True172 def read(self, count=-1):173 if count == 0:174 return ''175 result = self.source.read(count)176 if result:177 self.lastoutput = result[-1]178 return result179 self._append_return_code_as_test()180 return self.source.read(count)181 def readline(self):182 result = self.source.readline()183 if result:184 self.lastoutput = result[-1]185 return result186 self._append_return_code_as_test()187 return self.source.readline()188 def readlines(self):189 result = self.source.readlines()190 if result:191 self.lastoutput = result[-1][-1]192 self._append_return_code_as_test()193 result.extend(self.source.readlines())...

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