How to use _getenvdata method in tox

Best Python code snippet using tox_python

config.py

Source:config.py Github

copy

Full Screen

...544 reader.addsubstitutions(distshare=config.distshare)545 config.sdistsrc = reader.getpath("sdistsrc", None)546 config.setupdir = reader.getpath("setupdir", "{toxinidir}")547 config.logdir = config.toxworkdir.join("log")548 config.envlist, all_envs = self._getenvdata(reader)549 # factors used in config or predefined550 known_factors = self._list_section_factors("testenv")551 known_factors.update(default_factors)552 known_factors.add("python")553 # factors stated in config envlist554 stated_envlist = reader.getstring("envlist", replace=False)555 if stated_envlist:556 for env in _split_env(stated_envlist):557 known_factors.update(env.split('-'))558 # configure testenvs559 for name in all_envs:560 section = testenvprefix + name561 factors = set(name.split('-'))562 if section in self._cfg or factors <= known_factors:563 config.envconfigs[name] = \564 self.make_envconfig(name, section, reader._subs, config)565 all_develop = all(name in config.envconfigs566 and config.envconfigs[name].usedevelop567 for name in config.envlist)568 config.skipsdist = reader.getbool("skipsdist", all_develop)569 def _list_section_factors(self, section):570 factors = set()571 if section in self._cfg:572 for _, value in self._cfg[section].items():573 exprs = re.findall(r'^([\w{}\.,-]+)\:\s+', value, re.M)574 factors.update(*mapcat(_split_factor_expr, exprs))575 return factors576 def make_envconfig(self, name, section, subs, config):577 factors = set(name.split('-'))578 reader = SectionReader(section, self._cfg, fallbacksections=["testenv"],579 factors=factors)580 vc = TestenvConfig(config=config, envname=name, factors=factors, reader=reader)581 reader.addsubstitutions(**subs)582 reader.addsubstitutions(envname=name)583 for env_attr in config._testenv_attr:584 atype = env_attr.type585 if atype in ("bool", "path", "string", "dict", "argv", "argvlist"):586 meth = getattr(reader, "get" + atype)587 res = meth(env_attr.name, env_attr.default)588 elif atype == "space-separated-list":589 res = reader.getlist(env_attr.name, sep=" ")590 elif atype == "line-list":591 res = reader.getlist(env_attr.name, sep="\n")592 else:593 raise ValueError("unknown type %r" % (atype,))594 if env_attr.postprocess:595 res = env_attr.postprocess(testenv_config=vc, value=res)596 setattr(vc, env_attr.name, res)597 if atype == "path":598 reader.addsubstitutions(**{env_attr.name: res})599 if env_attr.name == "basepython":600 reader.addsubstitutions(envbindir=vc.envbindir, envpython=vc.envpython,601 envsitepackagesdir=vc.envsitepackagesdir)602 return vc603 def _getenvdata(self, reader):604 envstr = self.config.option.env \605 or os.environ.get("TOXENV") \606 or reader.getstring("envlist", replace=False) \607 or []608 envlist = _split_env(envstr)609 # collect section envs610 all_envs = set(envlist) - set(["ALL"])611 for section in self._cfg:612 if section.name.startswith(testenvprefix):613 all_envs.add(section.name[len(testenvprefix):])614 if not all_envs:615 all_envs.add("python")616 if not envlist or "ALL" in envlist:617 envlist = sorted(all_envs)...

Full Screen

Full Screen

_config.py

Source:_config.py Github

copy

Full Screen

...254 reader.addsubstitutions(distshare=config.distshare)255 config.sdistsrc = reader.getpath(toxsection, "sdistsrc", None)256 config.setupdir = reader.getpath(toxsection, "setupdir", "{toxinidir}")257 config.logdir = config.toxworkdir.join("log")258 config.envlist, all_envs = self._getenvdata(reader, toxsection)259 # configure testenvs260 known_factors = self._list_section_factors("testenv")261 known_factors.update(default_factors)262 known_factors.add("python")263 for name in all_envs:264 section = testenvprefix + name265 factors = set(name.split('-'))266 if section in self._cfg or factors <= known_factors:267 config.envconfigs[name] = \268 self._makeenvconfig(name, section, reader._subs, config)269 all_develop = all(name in config.envconfigs270 and config.envconfigs[name].develop271 for name in config.envlist)272 config.skipsdist = reader.getbool(toxsection, "skipsdist", all_develop)273 def _list_section_factors(self, section):274 factors = set()275 if section in self._cfg:276 for _, value in self._cfg[section].items():277 exprs = re.findall(r'^([\w{}\.,-]+)\:\s+', value, re.M)278 factors.update(*mapcat(_split_factor_expr, exprs))279 return factors280 def _makeenvconfig(self, name, section, subs, config):281 vc = VenvConfig(envname=name)282 vc.config = config283 factors = set(name.split('-'))284 reader = IniReader(self._cfg, fallbacksections=["testenv"],285 factors=factors)286 reader.addsubstitutions(**subs)287 vc.develop = not config.option.installpkg and \288 reader.getbool(section, "usedevelop", config.option.develop)289 vc.envdir = reader.getpath(section, "envdir", "{toxworkdir}/%s" % name)290 vc.args_are_paths = reader.getbool(section, "args_are_paths", True)291 if reader.getdefault(section, "python", None):292 raise tox.exception.ConfigError(293 "'python=' key was renamed to 'basepython='")294 bp = next((default_factors[f] for f in factors if f in default_factors),295 sys.executable)296 vc.basepython = reader.getdefault(section, "basepython", bp)297 vc._basepython_info = config.interpreters.get_info(vc.basepython)298 reader.addsubstitutions(envdir=vc.envdir, envname=vc.envname,299 envbindir=vc.envbindir, envpython=vc.envpython,300 envsitepackagesdir=vc.envsitepackagesdir)301 vc.envtmpdir = reader.getpath(section, "tmpdir", "{envdir}/tmp")302 vc.envlogdir = reader.getpath(section, "envlogdir", "{envdir}/log")303 reader.addsubstitutions(envlogdir=vc.envlogdir, envtmpdir=vc.envtmpdir)304 vc.changedir = reader.getpath(section, "changedir", "{toxinidir}")305 if config.option.recreate:306 vc.recreate = True307 else:308 vc.recreate = reader.getbool(section, "recreate", False)309 args = config.option.args310 if args:311 if vc.args_are_paths:312 args = []313 for arg in config.option.args:314 origpath = config.invocationcwd.join(arg, abs=True)315 if origpath.check():316 arg = vc.changedir.bestrelpath(origpath)317 args.append(arg)318 reader.addsubstitutions(args)319 setenv = {}320 if config.hashseed is not None:321 setenv['PYTHONHASHSEED'] = config.hashseed322 setenv.update(reader.getdict(section, 'setenv'))323 vc.setenv = setenv324 if not vc.setenv:325 vc.setenv = None326 vc.commands = reader.getargvlist(section, "commands")327 vc.whitelist_externals = reader.getlist(section,328 "whitelist_externals")329 vc.deps = []330 for depline in reader.getlist(section, "deps"):331 m = re.match(r":(\w+):\s*(\S+)", depline)332 if m:333 iname, name = m.groups()334 ixserver = config.indexserver[iname]335 else:336 name = depline.strip()337 ixserver = None338 name = self._replace_forced_dep(name, config)339 vc.deps.append(DepConfig(name, ixserver))340 vc.distribute = reader.getbool(section, "distribute", False)341 vc.sitepackages = self.config.option.sitepackages or \342 reader.getbool(section, "sitepackages", False)343 vc.downloadcache = None344 downloadcache = reader.getdefault(section, "downloadcache")345 if downloadcache:346 # env var, if present, takes precedence347 downloadcache = os.environ.get("PIP_DOWNLOAD_CACHE", downloadcache)348 vc.downloadcache = py.path.local(downloadcache)349 vc.install_command = reader.getargv(350 section,351 "install_command",352 "pip install {opts} {packages}",353 )354 if '{packages}' not in vc.install_command:355 raise tox.exception.ConfigError(356 "'install_command' must contain '{packages}' substitution")357 vc.pip_pre = config.option.pre or reader.getbool(358 section, "pip_pre", False)359 return vc360 def _getenvdata(self, reader, toxsection):361 envstr = self.config.option.env \362 or os.environ.get("TOXENV") \363 or reader.getdefault(toxsection, "envlist", replace=False) \364 or []365 envlist = _split_env(envstr)366 # collect section envs367 all_envs = set(envlist) - set(["ALL"])368 for section in self._cfg:369 if section.name.startswith(testenvprefix):370 all_envs.add(section.name[len(testenvprefix):])371 if not all_envs:372 all_envs.add("python")373 if not envlist or "ALL" in envlist:374 envlist = sorted(all_envs)...

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