Best Python code snippet using avocado_python
jobdata.py
Source:jobdata.py
...32def json_bad_variants_obj(item):33 for log in [LOG_UI, LOG_JOB]:34 log.warning("jobdata.variants: Unable to serialize '%s'", item)35 return str(item)36def record_suite_variant(path_variants, suite):37 with open(path_variants, "w", encoding="utf-8") as variants_file:38 variants = []39 variants += suite.variants.dump()40 json.dump(variants, variants_file, default=json_bad_variants_obj)41 variants_file.flush()42 os.fsync(variants_file)43def record(job, cmdline=None):44 """45 Records all required job information.46 """47 base_dir = init_dir(job.logdir, JOB_DATA_DIR)48 path_cfg = os.path.join(base_dir, CONFIG_FILENAME)49 path_references = os.path.join(base_dir, TEST_REFERENCES_FILENAME)50 path_pwd = os.path.join(base_dir, PWD_FILENAME)51 path_job_config = os.path.join(base_dir, JOB_CONFIG_FILENAME)52 path_cmdline = os.path.join(base_dir, CMDLINE_FILENAME)53 references = job.config.get("resolver.references")54 if references:55 with open(path_references, "w", encoding="utf-8") as references_file:56 references_file.write(f"{references}")57 references_file.flush()58 os.fsync(references_file)59 with open(path_cfg, "w", encoding="utf-8") as config_file:60 settings.config.write(config_file)61 config_file.flush()62 os.fsync(config_file)63 for idx, suite in enumerate(job.test_suites, 1):64 if suite.name:65 suite_var_name = f"variants-{idx}-{suite.name}.json"66 else:67 suite_var_name = f"variants-{idx}.json"68 suite_var_name = string_to_safe_path(suite_var_name)69 path_suite_variant = os.path.join(base_dir, suite_var_name)70 record_suite_variant(path_suite_variant, suite)71 with open(path_pwd, "w", encoding="utf-8") as pwd_file:72 pwd_file.write(f"{os.getcwd()}")73 pwd_file.flush()74 os.fsync(pwd_file)75 with open(path_job_config, "w", encoding="utf-8") as job_config_file:76 json.dump(job.config, job_config_file, cls=ConfigEncoder)77 job_config_file.flush()78 os.fsync(job_config_file)79 with open(path_cmdline, "w", encoding="utf-8") as cmdline_file:80 cmdline_file.write(f"{cmdline}")81 cmdline_file.flush()82 os.fsync(cmdline_file)83def _retrieve(resultsdir, resource):84 path = os.path.join(resultsdir, JOB_DATA_DIR, resource)...
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!!