Best Python code snippet using tappy_python
test_loader.py
Source: test_loader.py
...20 temp = tempfile.NamedTemporaryFile(delete=False)21 temp.write(sample.encode('utf-8'))22 temp.close()23 loader = Loader()24 suite = loader.load_suite_from_file(temp.name)25 # The bail line counts as a failed test.26 self.assertEqual(3, len(suite._tests))27 def test_file_does_not_exist(self):28 """The loader records a failure when a file does not exist."""29 loader = Loader()30 suite = loader.load_suite_from_file('phony.tap')31 self.assertEqual(1, len(suite._tests))32 self.assertEqual(33 'phony.tap does not exist.', suite._tests[0]._line.description)34 def test_handles_directory(self):35 directory = tempfile.mkdtemp()36 sub_directory = os.path.join(directory, 'sub')37 os.mkdir(sub_directory)38 with open(os.path.join(directory, 'a_file.tap'), 'w') as f:39 f.write('ok A passing test')40 with open(os.path.join(sub_directory, 'another_file.tap'), 'w') as f:41 f.write('not ok A failing test')42 loader = Loader()43 suite = loader.load([directory])44 self.assertEqual(2, len(suite._tests))45 def test_errors_with_multiple_version_lines(self):46 sample = inspect.cleandoc(47 """TAP version 1348 TAP version 1349 1..050 """)51 temp = tempfile.NamedTemporaryFile(delete=False)52 temp.write(sample.encode('utf-8'))53 temp.close()54 loader = Loader()55 suite = loader.load_suite_from_file(temp.name)56 self.assertEqual(1, len(suite._tests))57 self.assertEqual(58 'Multiple version lines appeared.',59 suite._tests[0]._line.description)60 def test_errors_with_version_not_on_first_line(self):61 sample = inspect.cleandoc(62 """# Something that doesn't belong.63 TAP version 1364 1..065 """)66 temp = tempfile.NamedTemporaryFile(delete=False)67 temp.write(sample.encode('utf-8'))68 temp.close()69 loader = Loader()70 suite = loader.load_suite_from_file(temp.name)71 self.assertEqual(1, len(suite._tests))72 self.assertEqual(73 'The version must be on the first line.',74 suite._tests[0]._line.description)75 def test_skip_plan_aborts_loading(self):76 sample = inspect.cleandoc(77 """1..0 # Skipping this test file.78 ok This should not get processed.79 """)80 temp = tempfile.NamedTemporaryFile(delete=False)81 temp.write(sample.encode('utf-8'))82 temp.close()83 loader = Loader()84 suite = loader.load_suite_from_file(temp.name)85 self.assertEqual(1, len(suite._tests))86 self.assertEqual(...
loader.py
Source: loader.py
...20 for filepath in files:21 if os.path.isdir(filepath):22 self._find_tests_in_directory(filepath, suite)23 else:24 suite.addTest(self.load_suite_from_file(filepath))25 return suite26 def load_suite_from_file(self, filename):27 """Load a test suite with test lines from the provided TAP file.28 :returns: A ``unittest.TestSuite`` instance29 """30 suite = unittest.TestSuite()31 rules = Rules(filename, suite)32 if not os.path.exists(filename):33 rules.handle_file_does_not_exist()34 return suite35 line_generator = self._parser.parse_file(filename)36 return self._load_lines(filename, line_generator, suite, rules)37 def load_suite_from_stdin(self):38 """Load a test suite with test lines from the TAP stream on STDIN.39 :returns: A ``unittest.TestSuite`` instance40 """41 suite = unittest.TestSuite()42 rules = Rules('stream', suite)43 line_generator = self._parser.parse_stdin()44 return self._load_lines('stream', line_generator, suite, rules)45 def _find_tests_in_directory(self, directory, suite):46 """Find test files in the directory and add them to the suite."""47 for dirpath, dirnames, filenames in os.walk(directory):48 for filename in filenames:49 filepath = os.path.join(dirpath, filename)50 suite.addTest(self.load_suite_from_file(filepath))51 def _load_lines(self, filename, line_generator, suite, rules):52 """Load a suite with lines produced by the line generator."""53 line_counter = 054 for line in line_generator:55 line_counter += 156 if line.category in self.ignored_lines:57 continue58 if line.category == 'test':59 suite.addTest(Adapter(filename, line))60 rules.saw_test()61 elif line.category == 'plan':62 if line.skip:63 rules.handle_skipping_plan(line)64 return suite...
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!!