Best Python code snippet using tempest_python
check_uuid.py
Source:check_uuid.py
...263 'test_node': tests[module_name]['tests'][test_name],264 'source_path': tests[module_name]['source_path']265 }266 return bool(self._filter_tests(report, tests))267 def report_untagged(self, tests):268 """Reports untagged tests if there are any. Returns true if269 untagged tests exist.270 """271 def report(module_name, test_name, tests):272 error_str = "%s:%s\nmissing @test.idempotent_id('...')\n%s\n" % (273 tests[module_name]['source_path'],274 tests[module_name]['tests'][test_name].lineno,275 test_name276 )277 print(error_str)278 return True279 return bool(self._filter_tests(report, tests))280 def fix_tests(self, tests):281 """Add uuids to all tests specified in tests and282 fix it in source files283 """284 patcher = SourcePatcher()285 for module_name in tests:286 add_import_once = True287 for test_name in tests[module_name]['tests']:288 if not tests[module_name]['import_valid'] and add_import_once:289 self._add_import_for_test_uuid(290 patcher,291 tests[module_name]['ast'],292 tests[module_name]['source_path']293 )294 add_import_once = False295 self._add_uuid_to_test(296 patcher, tests[module_name]['tests'][test_name],297 tests[module_name]['source_path'])298 patcher.apply_patches()299def run():300 parser = argparse.ArgumentParser()301 parser.add_argument('--package', action='store', dest='package',302 default='tempest', type=str,303 help='Package with tests')304 parser.add_argument('--fix', action='store_true', dest='fix_tests',305 help='Attempt to fix tests without UUIDs')306 args = parser.parse_args()307 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))308 pkg = importlib.import_module(args.package)309 checker = TestChecker(pkg)310 errors = False311 tests = checker.get_tests()312 untagged = checker.find_untagged(tests)313 errors = checker.report_collisions(tests) or errors314 if args.fix_tests and untagged:315 checker.fix_tests(untagged)316 else:317 errors = checker.report_untagged(untagged) or errors318 if errors:319 sys.exit("@test.idempotent_id existence and uniqueness checks failed\n"320 "Run 'tox -v -euuidgen' to automatically fix tests with\n"321 "missing @test.idempotent_id decorators.")322if __name__ == '__main__':...
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!!