How to use _find_simple_test_candidates method in avocado

Best Python code snippet using avocado_python

test_job.py

Source:test_job.py Github

copy

Full Screen

...11from avocado.core import exit_codes12from avocado.utils import path as utils_path13class JobTest(unittest.TestCase):14 @staticmethod15 def _find_simple_test_candidates(candidates=['true', 'time', 'uptime']):16 found = []17 for candidate in candidates:18 try:19 found.append(utils_path.find_command(candidate))20 except utils_path.CmdNotFoundError:21 pass22 return found23 def test_job_empty_suite(self):24 args = argparse.Namespace()25 empty_job = job.Job(args)26 self.assertIsNone(empty_job.test_suite)27 def test_job_empty_has_id(self):28 args = argparse.Namespace()29 empty_job = job.Job(args)30 self.assertIsNotNone(empty_job.unique_id)31 def test_job_test_suite_not_created(self):32 args = argparse.Namespace()33 myjob = job.Job(args)34 self.assertIsNone(myjob.test_suite)35 def test_job_create_test_suite_empty(self):36 args = argparse.Namespace()37 myjob = job.Job(args)38 self.assertRaises(exceptions.OptionValidationError,39 myjob.create_test_suite)40 #def test_job_pre_tests(self):41 # class JobFilterTime(job.Job):42 # def pre_tests(self):43 # filtered_test_suite = []44 # for test_factory in self.test_suite:45 # if test_factory[0] is test.SimpleTest:46 # if not test_factory[1].get('name', '').endswith('time'):47 # filtered_test_suite.append(test_factory)48 # self.test_suite = filtered_test_suite49 # super(JobFilterTime, self).pre_tests()50 # simple_tests_found = self._find_simple_test_candidates()51 # args = argparse.Namespace(reference=simple_tests_found)52 # myjob = JobFilterTime(args)53 # myjob.create_test_suite()54 # myjob.pre_tests()55 # self.assertLessEqual(len(myjob.test_suite), 1)56 def test_job_run_tests(self):57 simple_tests_found = self._find_simple_test_candidates(['true'])58 args = argparse.Namespace(reference=simple_tests_found)59 myjob = job.Job(args)60 myjob.create_test_suite()61 self.assertEqual(myjob.run_tests(),62 exit_codes.AVOCADO_ALL_OK)63 #def test_job_post_tests(self):64 # class JobLogPost(job.Job):65 # def post_tests(self):66 # with open(os.path.join(self.logdir, "reversed_id"), "w") as f:67 # f.write(self.unique_id[::-1])68 # super(JobLogPost, self).post_tests()69 # simple_tests_found = self._find_simple_test_candidates()70 # args = argparse.Namespace(reference=simple_tests_found)71 # myjob = JobLogPost(args)72 # myjob.create_test_suite()73 # myjob.pre_tests()74 # myjob.run_tests()75 # myjob.post_tests()76 # self.assertEqual(myjob.unique_id[::-1],77 # open(os.path.join(myjob.logdir, "reversed_id")).read())78 @unittest.skip("Issue described at https://trello.com/c/qgSTIK0Y")79 def test_job_run(self):80 class JobFilterLog(job.Job):81 def pre_tests(self):82 filtered_test_suite = []83 for test_factory in self.test_suite:84 if test_factory[0] is test.SimpleTest:85 if not test_factory[1].get('name', '').endswith('time'):86 filtered_test_suite.append(test_factory)87 self.test_suite = filtered_test_suite88 super(JobFilterLog, self).pre_tests()89 def post_tests(self):90 with open(os.path.join(self.logdir, "reversed_id"), "w") as f:91 f.write(self.unique_id[::-1])92 super(JobFilterLog, self).post_tests()93 simple_tests_found = self._find_simple_test_candidates()94 args = argparse.Namespace(reference=simple_tests_found)95 myjob = JobFilterLog(args)96 self.assertEqual(myjob.run(),97 exit_codes.AVOCADO_ALL_OK)98 self.assertLessEqual(len(myjob.test_suite), 1)99 self.assertEqual(myjob.unique_id[::-1],100 open(os.path.join(myjob.logdir, "reversed_id")).read())101if __name__ == '__main__':...

Full Screen

Full Screen

test_suite.py

Source:test_suite.py Github

copy

Full Screen

...11 data_dir._tmp_tracker.unittest_refresh_dir_tracker()12 prefix = temp_dir_prefix(__name__, self, 'setUp')13 self.tmpdir = tempfile.TemporaryDirectory(prefix=prefix)14 @staticmethod15 def _find_simple_test_candidates(candidates=None):16 if candidates is None:17 candidates = ['true']18 found = []19 for candidate in candidates:20 try:21 found.append(utils_path.find_command(candidate))22 except utils_path.CmdNotFoundError:23 pass24 return found25 def test_custom_suite(self):26 """Custom suites should assume custom tests.27 When using custom suites (from constructor) we are assuming no28 magic, no tests should be created from run.references.29 """30 tests = self._find_simple_test_candidates()31 config = {'run.results_dir': self.tmpdir.name,32 'core.show': ['none'],33 'run.references': tests}34 self.suite = TestSuite(name='foo', config=config)35 self.assertEqual(0, self.suite.size)36 def test_automatic_suite(self):37 """Automatic suites should create tests.38 When using automatic suites we are assuming magic,39 and, tests should be created from run.references.40 """41 tests = self._find_simple_test_candidates()42 config = {'run.results_dir': self.tmpdir.name,43 'core.show': ['none'],44 'run.references': tests}45 self.suite = TestSuite.from_config(config=config)46 self.assertEqual(1, self.suite.size)47 def test_config_extend_manual(self):48 """Test extends config from job when using manual method."""49 tests = self._find_simple_test_candidates()50 job_config = {'run.results_dir': self.tmpdir.name,51 'core.show': ['none']}52 suite_config = {'run.references': tests}53 self.suite = TestSuite(name='foo',54 config=suite_config,55 job_config=job_config)56 self.assertEqual(self.suite.config.get('core.show'), ['none'])57 def test_config_extend_automatic(self):58 """Test extends config from job when using automatic method."""59 tests = self._find_simple_test_candidates()60 job_config = {'run.results_dir': self.tmpdir.name,61 'core.show': ['none']}62 suite_config = {'run.references': tests}63 self.suite = TestSuite.from_config(config=suite_config,64 job_config=job_config)65 self.assertEqual(self.suite.config.get('core.show'), ['none'])66 def tearDown(self):67 data_dir._tmp_tracker.unittest_refresh_dir_tracker()68 self.tmpdir.cleanup()69if __name__ == '__main__':...

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