Best Python code snippet using avocado_python
test.py
Source:test.py  
...454                                      "details.")455        self.status = 'PASS'456        if self.sysinfo_enabled:457            self.sysinfo_logger.end_test_hook()458    def _setup_environment_variables(self):459        os.environ['AVOCADO_VERSION'] = VERSION460        if self.basedir is not None:461            os.environ['AVOCADO_TEST_BASEDIR'] = self.basedir462        if self.datadir is not None:463            os.environ['AVOCADO_TEST_DATADIR'] = self.datadir464        os.environ['AVOCADO_TEST_WORKDIR'] = self.workdir465        os.environ['AVOCADO_TEST_SRCDIR'] = self.srcdir466        os.environ['AVOCADO_TEST_LOGDIR'] = self.logdir467        os.environ['AVOCADO_TEST_LOGFILE'] = self.logfile468        os.environ['AVOCADO_TEST_OUTPUTDIR'] = self.outputdir469        if self.sysinfo_enabled:470            os.environ['AVOCADO_TEST_SYSINFODIR'] = self.sysinfodir471    def run_avocado(self):472        """473        Wraps the run method, for execution inside the avocado runner.474        :result: Unused param, compatibility with :class:`unittest.TestCase`.475        """476        self._setup_environment_variables()477        try:478            self._tag_start()479            self._run_avocado()480        except exceptions.TestBaseException as detail:481            self.status = detail.status482            self.fail_class = detail.__class__.__name__483            self.fail_reason = detail484            self.traceback = stacktrace.prepare_exc_info(sys.exc_info())485        except AssertionError as detail:486            self.status = 'FAIL'487            self.fail_class = detail.__class__.__name__488            self.fail_reason = detail489            self.traceback = stacktrace.prepare_exc_info(sys.exc_info())490        except Exception as detail:..._spark.py
Source:_spark.py  
...5ENV_VARIABLES = read_settings('ENV_VARIABLES')6APP_NAME = read_settings('APP_NAME')7VENV_PATH = read_settings('VENV_PATH')8SPARK_CONFIG = read_settings('SPARK_CONFIG')9def _setup_environment_variables() -> None:10    if ENV_VARIABLES is not None and isinstance(ENV_VARIABLES, dict):11        for k, v in ENV_VARIABLES.items():12            os.environ[k] = v13def get_spark_session() -> SparkSession:14    _setup_environment_variables()15    warehouse_location = osp.abspath('spark-warehouse')16    SparkSession.builder.appName(APP_NAME)17    SparkSession.builder.config("spark.sql.warehouse.dir", warehouse_location)18    for k, v in SPARK_CONFIG:19        SparkSession.builder.config(k, v)20    SparkSession.builder.config("spark.yarn.appMasterEnv.PYSPARK_PYTHON", "./pyenv/bin/python")21    SparkSession.builder.config("spark.yarn.dist.archives", f"{VENV_PATH}#pyenv")22    SparkSession.builder.enableHiveSupport()23    context = SparkSession.builder.getOrCreate()...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!!
