How to use _reget_config method in molecule

Best Python code snippet using molecule_python

config.py

Source:config.py Github

copy

Full Screen

...78 self.config = self._get_config()79 self._action = None80 self._run_uuid = str(uuid4())81 def after_init(self):82 self.config = self._reget_config()83 if self.molecule_file:84 self._validate()85 def write(self):86 util.write_file(self.config_file, util.safe_dump(self.config))87 @property88 def config_file(self):89 return os.path.join(self.scenario.ephemeral_directory, MOLECULE_FILE)90 @property91 def is_parallel(self):92 return self.command_args.get("parallel", False)93 @property94 def debug(self):95 return self.args.get("debug", MOLECULE_DEBUG)96 @property97 def env_file(self):98 return util.abs_path(self.args.get("env_file"))99 @property100 def subcommand(self):101 return self.command_args["subcommand"]102 @property103 def action(self):104 return self._action105 @action.setter106 def action(self, value):107 self._action = value108 @property109 def project_directory(self):110 return os.getenv("MOLECULE_PROJECT_DIRECTORY", os.getcwd())111 @property112 def cache_directory(self):113 return "molecule_parallel" if self.is_parallel else "molecule"114 @property115 def molecule_directory(self):116 return molecule_directory(self.project_directory)117 @property # type: ignore # see https://github.com/python/mypy/issues/1362118 @util.lru_cache()119 def dependency(self):120 dependency_name = self.config["dependency"]["name"]121 if dependency_name == "galaxy":122 return ansible_galaxy.AnsibleGalaxy(self)123 elif dependency_name == "gilt":124 return gilt.Gilt(self)125 elif dependency_name == "shell":126 return shell.Shell(self)127 @property # type: ignore128 @util.lru_cache()129 def driver(self):130 driver_name = self._get_driver_name()131 driver = None132 driver = api.drivers(config=self)[driver_name]133 driver.name = driver_name134 return driver135 @property # type: ignore136 def env(self):137 return {138 "MOLECULE_DEBUG": str(self.debug),139 "MOLECULE_FILE": self.config_file,140 "MOLECULE_ENV_FILE": str(self.env_file),141 "MOLECULE_STATE_FILE": self.state.state_file,142 "MOLECULE_INVENTORY_FILE": self.provisioner.inventory_file,143 "MOLECULE_EPHEMERAL_DIRECTORY": self.scenario.ephemeral_directory,144 "MOLECULE_SCENARIO_DIRECTORY": self.scenario.directory,145 "MOLECULE_PROJECT_DIRECTORY": self.project_directory,146 "MOLECULE_INSTANCE_CONFIG": self.driver.instance_config,147 "MOLECULE_DEPENDENCY_NAME": self.dependency.name,148 "MOLECULE_DRIVER_NAME": self.driver.name,149 "MOLECULE_PROVISIONER_NAME": self.provisioner.name,150 "MOLECULE_SCENARIO_NAME": self.scenario.name,151 "MOLECULE_VERIFIER_NAME": self.verifier.name,152 "MOLECULE_VERIFIER_TEST_DIRECTORY": self.verifier.directory,153 }154 @property # type: ignore155 @util.lru_cache()156 def lint(self):157 lint_name = self.config.get("lint", None)158 return lint_name159 @property # type: ignore160 @util.lru_cache()161 def platforms(self):162 return platforms.Platforms(self, parallelize_platforms=self.is_parallel)163 @property # type: ignore164 @util.lru_cache()165 def provisioner(self):166 provisioner_name = self.config["provisioner"]["name"]167 if provisioner_name == "ansible":168 return ansible.Ansible(self)169 @property # type: ignore170 @util.lru_cache()171 def scenario(self):172 return scenario.Scenario(self)173 @property # type: ignore174 @util.lru_cache()175 def state(self):176 return state.State(self)177 @property # type: ignore178 @util.lru_cache()179 def verifier(self):180 return api.verifiers(self).get(self.config["verifier"]["name"], None)181 def _get_driver_name(self):182 driver_from_state_file = self.state.driver183 driver_from_cli = self.command_args.get("driver_name")184 if driver_from_state_file:185 driver_name = driver_from_state_file186 elif driver_from_cli:187 driver_name = driver_from_cli188 else:189 driver_name = self.config["driver"]["name"]190 if driver_from_cli and (driver_from_cli != driver_name):191 msg = (192 "Instance(s) were created with the '{}' driver, but the "193 "subcommand is using '{}' driver."194 ).format(driver_name, driver_from_cli)195 util.sysexit_with_message(msg)196 return driver_name197 def _get_config(self):198 """199 Perform a prioritized recursive merge of config files.200 Returns a new dict. Prior to merging the config files are interpolated with201 environment variables.202 :return: dict203 """204 return self._combine(keep_string=MOLECULE_KEEP_STRING)205 def _reget_config(self):206 """207 Perform the same prioritized recursive merge from `get_config`.208 Interpolates the ``keep_string`` left behind in the original209 ``get_config`` call. This is probably __very__ bad.210 :return: dict211 """212 env = util.merge_dicts(os.environ, self.env)213 env = set_env_from_file(env, self.env_file)214 return self._combine(env=env)215 def _combine(self, env=os.environ, keep_string=None):216 """217 Perform a prioritized recursive merge of config files.218 Returns a new dict. Prior to merging the config files are interpolated with219 environment variables....

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