How to use _write_test_case_header method in tappy

Best Python code snippet using tappy_python

tracker.py

Source:tracker.py Github

copy

Full Screen

...41 def _track(self, class_name):42 """Keep track of which test cases have executed."""43 if self._test_cases.get(class_name) is None:44 if self.streaming and self.header:45 self._write_test_case_header(class_name, self.stream)46 self._test_cases[class_name] = []47 if self.combined:48 self.combined_test_cases_seen.append(class_name)49 def add_ok(self, class_name, description, directive=''):50 result = Result(51 ok=True, number=self._get_next_line_number(class_name),52 description=description, directive=Directive(directive))53 self._add_line(class_name, result)54 def add_not_ok(55 self, class_name, description, directive='', diagnostics=None):56 result = Result(57 ok=False, number=self._get_next_line_number(class_name),58 description=description, diagnostics=diagnostics,59 directive=Directive(directive))60 self._add_line(class_name, result)61 def add_skip(self, class_name, description, reason):62 directive = 'SKIP {0}'.format(reason)63 result = Result(64 ok=True, number=self._get_next_line_number(class_name),65 description=description, directive=Directive(directive))66 self._add_line(class_name, result)67 def _add_line(self, class_name, result):68 self._track(class_name)69 if self.streaming:70 print(result, file=self.stream)71 self._test_cases[class_name].append(result)72 def _get_next_line_number(self, class_name):73 if self.combined or self.streaming:74 # This has an obvious side effect. Oh well.75 self.combined_line_number += 176 return self.combined_line_number77 else:78 try:79 return len(self._test_cases[class_name]) + 180 except KeyError:81 # A result is created before the call to _track so the test82 # case may not be tracked yet. In that case, the line is 1.83 return 184 def generate_tap_reports(self):85 """Generate TAP reports.86 The results are either combined into a single output file or87 the output file name is generated from the test case.88 """89 if self.streaming:90 # The results already went to the stream, record the plan.91 print('1..{0}'.format(self.combined_line_number), file=self.stream)92 return93 if self.combined:94 combined_file = 'testresults.tap'95 if self.outdir:96 combined_file = os.path.join(self.outdir, combined_file)97 with open(combined_file, 'w') as out_file:98 for test_case in self.combined_test_cases_seen:99 self.generate_tap_report(100 test_case, self._test_cases[test_case], out_file)101 print(102 '1..{0}'.format(self.combined_line_number), file=out_file)103 else:104 for test_case, tap_lines in self._test_cases.items():105 with open(self._get_tap_file_path(test_case), 'w') as out_file:106 self.generate_tap_report(test_case, tap_lines, out_file)107 def generate_tap_report(self, test_case, tap_lines, out_file):108 self._write_test_case_header(test_case, out_file)109 for tap_line in tap_lines:110 print(tap_line, file=out_file)111 # For combined results, the plan is only output once after112 # all the test cases complete.113 if not self.combined:114 print('1..{0}'.format(len(tap_lines)), file=out_file)115 def _write_test_case_header(self, test_case, stream):116 print(_('# TAP results for {test_case}').format(117 test_case=test_case), file=stream)118 def _get_tap_file_path(self, test_case):119 """Get the TAP output file path for the test case."""120 sanitized_test_case = test_case.translate(self._sanitized_table)121 tap_file = sanitized_test_case + '.tap'122 if self.outdir:123 return os.path.join(self.outdir, tap_file)...

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