Best Python code snippet using tappy_python
tracker.py
Source: tracker.py
...37 # Internal state for tracking each test case.38 self._test_cases = {}39 self._sanitized_table = str.maketrans(" \\/\n", "----")40 if self.streaming:41 self._write_tap_version(self.stream)42 if self.plan is not None:43 self._write_plan(self.stream)44 def _get_outdir(self):45 return self._outdir46 def _set_outdir(self, outdir):47 self._outdir = outdir48 if outdir and not os.path.exists(outdir):49 os.makedirs(outdir)50 outdir = property(_get_outdir, _set_outdir)51 def _track(self, class_name):52 """Keep track of which test cases have executed."""53 if self._test_cases.get(class_name) is None:54 if self.streaming and self.header:55 self._write_test_case_header(class_name, self.stream)56 self._test_cases[class_name] = []57 if self.combined:58 self.combined_test_cases_seen.append(class_name)59 def add_ok(self, class_name, description, directive=""):60 result = Result(61 ok=True,62 number=self._get_next_line_number(class_name),63 description=description,64 directive=Directive(directive),65 )66 self._add_line(class_name, result)67 def add_not_ok(self, class_name, description, directive="", diagnostics=None):68 result = Result(69 ok=False,70 number=self._get_next_line_number(class_name),71 description=description,72 diagnostics=diagnostics,73 directive=Directive(directive),74 )75 self._add_line(class_name, result)76 def add_skip(self, class_name, description, reason):77 directive = "SKIP {0}".format(reason)78 result = Result(79 ok=True,80 number=self._get_next_line_number(class_name),81 description=description,82 directive=Directive(directive),83 )84 self._add_line(class_name, result)85 def _add_line(self, class_name, result):86 self._track(class_name)87 if self.streaming:88 print(result, file=self.stream)89 self._test_cases[class_name].append(result)90 def _get_next_line_number(self, class_name):91 if self.combined or self.streaming:92 # This has an obvious side effect. Oh well.93 self.combined_line_number += 194 return self.combined_line_number95 else:96 try:97 return len(self._test_cases[class_name]) + 198 except KeyError:99 # A result is created before the call to _track so the test100 # case may not be tracked yet. In that case, the line is 1.101 return 1102 def set_plan(self, total):103 """Notify the tracker how many total tests there will be."""104 self.plan = total105 if self.streaming:106 # This will only write the plan if we haven't written it107 # already but we want to check if we already wrote a108 # test out (in which case we can't just write the plan out109 # right here).110 if not self.combined_test_cases_seen:111 self._write_plan(self.stream)112 elif not self.combined:113 raise ValueError(114 "set_plan can only be used with combined or streaming output"115 )116 def generate_tap_reports(self):117 """Generate TAP reports.118 The results are either combined into a single output file or119 the output file name is generated from the test case.120 """121 if self.streaming:122 # We're streaming but set_plan wasn't called, so we can only123 # know the plan now (at the end).124 if not self._plan_written:125 print("1..{0}".format(self.combined_line_number), file=self.stream)126 self._plan_written = True127 return128 if self.combined:129 combined_file = "testresults.tap"130 if self.outdir:131 combined_file = os.path.join(self.outdir, combined_file)132 with open(combined_file, "w") as out_file:133 self._write_tap_version(out_file)134 if self.plan is not None:135 print("1..{0}".format(self.plan), file=out_file)136 for test_case in self.combined_test_cases_seen:137 self.generate_tap_report(138 test_case, self._test_cases[test_case], out_file139 )140 if self.plan is None:141 print("1..{0}".format(self.combined_line_number), file=out_file)142 else:143 for test_case, tap_lines in self._test_cases.items():144 with open(self._get_tap_file_path(test_case), "w") as out_file:145 self._write_tap_version(out_file)146 self.generate_tap_report(test_case, tap_lines, out_file)147 def generate_tap_report(self, test_case, tap_lines, out_file):148 self._write_test_case_header(test_case, out_file)149 for tap_line in tap_lines:150 print(tap_line, file=out_file)151 # For combined results, the plan is only output once after152 # all the test cases complete.153 if not self.combined:154 print("1..{0}".format(len(tap_lines)), file=out_file)155 def _write_tap_version(self, filename):156 """Write a Version 13 TAP row.157 ``filename`` can be a filename or a stream.158 """159 if ENABLE_VERSION_13:160 print("TAP version 13", file=filename)161 def _write_plan(self, stream):162 """Write the plan line to the stream.163 If we have a plan and have not yet written it out, write it to164 the given stream.165 """166 if self.plan is not None:167 if not self._plan_written:168 print("1..{0}".format(self.plan), file=stream)169 self._plan_written = True...
Check out the latest blogs from LambdaTest on this topic:
Many theoretical descriptions explain the role of the Scrum Master as a vital member of the Scrum team. However, these descriptions do not provide an honest answer to the fundamental question: “What are the day-to-day activities of a Scrum Master?”
The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.
The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.
When most firms employed a waterfall development model, it was widely joked about in the industry that Google kept its products in beta forever. Google has been a pioneer in making the case for in-production testing. Traditionally, before a build could go live, a tester was responsible for testing all scenarios, both defined and extempore, in a testing environment. However, this concept is evolving on multiple fronts today. For example, the tester is no longer testing alone. Developers, designers, build engineers, other stakeholders, and end users, both inside and outside the product team, are testing the product and providing feedback.
I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!