How to use cli_skip_missing_interpreter method in tox

Best Python code snippet using tox_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...445 )446 parser.add_argument(447 "--alwayscopy", action="store_true", help="override alwayscopy setting to True in all envs"448 )449 cli_skip_missing_interpreter(parser)450 parser.add_argument(451 "--workdir",452 action="store",453 dest="workdir",454 metavar="PATH",455 default=None,456 help="tox working directory",457 )458 parser.add_argument(459 "args", nargs="*", help="additional arguments available to command positional substitution"460 )461 parser.add_testenv_attribute(462 name="envdir",463 type="path",464 default="{toxworkdir}/{envname}",465 help="set venv directory -- be very careful when changing this as tox "466 "will remove this directory when recreating an environment",467 )468 # add various core venv interpreter attributes469 def setenv(testenv_config, value):470 setenv = value471 config = testenv_config.config472 if "PYTHONHASHSEED" not in setenv and config.hashseed is not None:473 setenv["PYTHONHASHSEED"] = config.hashseed474 setenv["TOX_ENV_NAME"] = str(testenv_config.envname)475 setenv["TOX_ENV_DIR"] = str(testenv_config.envdir)476 return setenv477 parser.add_testenv_attribute(478 name="setenv",479 type="dict_setenv",480 postprocess=setenv,481 help="list of X=Y lines with environment variable settings",482 )483 def basepython_default(testenv_config, value):484 """either user set or proposed from the factor name485 in both cases we check that the factor name implied python version and the resolved486 python interpreter version match up; if they don't we warn, unless ignore base487 python conflict is set in which case the factor name implied version if forced488 """489 for factor in testenv_config.factors:490 if factor in tox.PYTHON.DEFAULT_FACTORS:491 implied_python = tox.PYTHON.DEFAULT_FACTORS[factor]492 break493 else:494 implied_python, factor = None, None495 if testenv_config.config.ignore_basepython_conflict and implied_python is not None:496 return implied_python497 proposed_python = (implied_python or sys.executable) if value is None else str(value)498 if implied_python is not None and implied_python != proposed_python:499 testenv_config.basepython = proposed_python500 match = tox.PYTHON.PY_FACTORS_RE.match(factor)501 implied_version = match.group(2) if match else None502 if implied_version is not None:503 python_info_for_proposed = testenv_config.python_info504 if not isinstance(python_info_for_proposed, NoInterpreterInfo):505 proposed_version = "".join(506 str(i) for i in python_info_for_proposed.version_info[0:2]507 )508 # '27'.startswith('2') or '27'.startswith('27')509 if not proposed_version.startswith(implied_version):510 # TODO(stephenfin): Raise an exception here in tox 4.0511 warnings.warn(512 "conflicting basepython version (set {}, should be {}) for env '{}';"513 "resolve conflict or set ignore_basepython_conflict".format(514 proposed_version, implied_version, testenv_config.envname515 )516 )517 return proposed_python518 parser.add_testenv_attribute(519 name="basepython",520 type="basepython",521 default=None,522 postprocess=basepython_default,523 help="executable name or path of interpreter used to create a virtual test environment.",524 )525 def merge_description(testenv_config, value):526 """the reader by default joins generated description with new line,527 replace new line with space"""528 return value.replace("\n", " ")529 parser.add_testenv_attribute(530 name="description",531 type="string",532 default="",533 postprocess=merge_description,534 help="short description of this environment",535 )536 parser.add_testenv_attribute(537 name="envtmpdir", type="path", default="{envdir}/tmp", help="venv temporary directory"538 )539 parser.add_testenv_attribute(540 name="envlogdir", type="path", default="{envdir}/log", help="venv log directory"541 )542 parser.add_testenv_attribute(543 name="downloadcache",544 type="string",545 default=None,546 help="(ignored) has no effect anymore, pip-8 uses local caching by default",547 )548 parser.add_testenv_attribute(549 name="changedir",550 type="path",551 default="{toxinidir}",552 help="directory to change to when running commands",553 )554 parser.add_testenv_attribute_obj(PosargsOption())555 parser.add_testenv_attribute(556 name="skip_install",557 type="bool",558 default=False,559 help="Do not install the current package. This can be used when you need the virtualenv "560 "management but do not want to install the current package",561 )562 parser.add_testenv_attribute(563 name="ignore_errors",564 type="bool",565 default=False,566 help="if set to True all commands will be executed irrespective of their result error "567 "status.",568 )569 def recreate(testenv_config, value):570 if testenv_config.config.option.recreate:571 return True572 return value573 parser.add_testenv_attribute(574 name="recreate",575 type="bool",576 default=False,577 postprocess=recreate,578 help="always recreate this test environment.",579 )580 def passenv(testenv_config, value):581 # Flatten the list to deal with space-separated values.582 value = list(itertools.chain.from_iterable([x.split(" ") for x in value]))583 passenv = {584 "PATH",585 "PIP_INDEX_URL",586 "LANG",587 "LANGUAGE",588 "LD_LIBRARY_PATH",589 "TOX_WORK_DIR",590 str(REPORTER_TIMESTAMP_ON_ENV),591 str(PARALLEL_ENV_VAR_KEY),592 }593 # read in global passenv settings594 p = os.environ.get("TOX_TESTENV_PASSENV", None)595 if p is not None:596 env_values = [x for x in p.split() if x]597 value.extend(env_values)598 # we ensure that tmp directory settings are passed on599 # we could also set it to the per-venv "envtmpdir"600 # but this leads to very long paths when run with jenkins601 # so we just pass it on by default for now.602 if tox.INFO.IS_WIN:603 passenv.add("SYSTEMDRIVE") # needed for pip6604 passenv.add("SYSTEMROOT") # needed for python's crypto module605 passenv.add("PATHEXT") # needed for discovering executables606 passenv.add("COMSPEC") # needed for distutils cygwincompiler607 passenv.add("TEMP")608 passenv.add("TMP")609 # for `multiprocessing.cpu_count()` on Windows (prior to Python 3.4).610 passenv.add("NUMBER_OF_PROCESSORS")611 passenv.add("PROCESSOR_ARCHITECTURE") # platform.machine()612 passenv.add("USERPROFILE") # needed for `os.path.expanduser()`613 passenv.add("MSYSTEM") # fixes #429614 else:615 passenv.add("TMPDIR")616 for spec in value:617 for name in os.environ:618 if fnmatchcase(name.upper(), spec.upper()):619 passenv.add(name)620 return passenv621 parser.add_testenv_attribute(622 name="passenv",623 type="line-list",624 postprocess=passenv,625 help="environment variables needed during executing test commands (taken from invocation "626 "environment). Note that tox always passes through some basic environment variables "627 "which are needed for basic functioning of the Python system. See --showconfig for the "628 "eventual passenv setting.",629 )630 parser.add_testenv_attribute(631 name="whitelist_externals",632 type="line-list",633 help="each lines specifies a path or basename for which tox will not warn "634 "about it coming from outside the test environment.",635 )636 parser.add_testenv_attribute(637 name="platform",638 type="string",639 default=".*",640 help="regular expression which must match against ``sys.platform``. "641 "otherwise testenv will be skipped.",642 )643 def sitepackages(testenv_config, value):644 return testenv_config.config.option.sitepackages or value645 def alwayscopy(testenv_config, value):646 return testenv_config.config.option.alwayscopy or value647 parser.add_testenv_attribute(648 name="sitepackages",649 type="bool",650 default=False,651 postprocess=sitepackages,652 help="Set to ``True`` if you want to create virtual environments that also "653 "have access to globally installed packages.",654 )655 parser.add_testenv_attribute(656 "download",657 type="bool",658 default=False,659 help="download the latest pip, setuptools and wheel when creating the virtual"660 "environment (default is to use the one bundled in virtualenv)",661 )662 parser.add_testenv_attribute(663 name="alwayscopy",664 type="bool",665 default=False,666 postprocess=alwayscopy,667 help="Set to ``True`` if you want virtualenv to always copy files rather "668 "than symlinking.",669 )670 def pip_pre(testenv_config, value):671 return testenv_config.config.option.pre or value672 parser.add_testenv_attribute(673 name="pip_pre",674 type="bool",675 default=False,676 postprocess=pip_pre,677 help="If ``True``, adds ``--pre`` to the ``opts`` passed to the install command. ",678 )679 def develop(testenv_config, value):680 option = testenv_config.config.option681 return not option.installpkg and (value or option.develop)682 parser.add_testenv_attribute(683 name="usedevelop",684 type="bool",685 postprocess=develop,686 default=False,687 help="install package in develop/editable mode",688 )689 parser.add_testenv_attribute_obj(InstallcmdOption())690 parser.add_testenv_attribute(691 name="list_dependencies_command",692 type="argv",693 default="python -m pip freeze",694 help="list dependencies for a virtual environment",695 )696 parser.add_testenv_attribute_obj(DepOption())697 parser.add_testenv_attribute(698 name="commands",699 type="argvlist",700 default="",701 help="each line specifies a test command and can use substitution.",702 )703 parser.add_testenv_attribute(704 name="commands_pre",705 type="argvlist",706 default="",707 help="each line specifies a setup command action and can use substitution.",708 )709 parser.add_testenv_attribute(710 name="commands_post",711 type="argvlist",712 default="",713 help="each line specifies a teardown command and can use substitution.",714 )715 parser.add_testenv_attribute(716 "ignore_outcome",717 type="bool",718 default=False,719 help="if set to True a failing result of this testenv will not make "720 "tox fail, only a warning will be produced",721 )722 parser.add_testenv_attribute(723 "extras",724 type="line-list",725 help="list of extras to install with the source distribution or develop install",726 )727 add_parallel_config(parser)728def cli_skip_missing_interpreter(parser):729 class SkipMissingInterpreterAction(argparse.Action):730 def __call__(self, parser, namespace, values, option_string=None):731 value = "true" if values is None else values732 if value not in ("config", "true", "false"):733 raise argparse.ArgumentTypeError("value must be config, true or false")734 setattr(namespace, self.dest, value)735 parser.add_argument(736 "-s",737 "--skip-missing-interpreters",738 default="config",739 metavar="val",740 nargs="?",741 action=SkipMissingInterpreterAction,742 help="don't fail tests for missing interpreters: {config,true,false} choice",...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...429 )430 parser.add_argument(431 "--alwayscopy", action="store_true", help="override alwayscopy setting to True in all envs"432 )433 cli_skip_missing_interpreter(parser)434 parser.add_argument(435 "--workdir",436 action="store",437 dest="workdir",438 metavar="PATH",439 default=None,440 help="tox working directory",441 )442 parser.add_argument(443 "args", nargs="*", help="additional arguments available to command positional substitution"444 )445 parser.add_testenv_attribute(446 name="envdir",447 type="path",448 default="{toxworkdir}/{envname}",449 help="set venv directory -- be very careful when changing this as tox "450 "will remove this directory when recreating an environment",451 )452 # add various core venv interpreter attributes453 def setenv(testenv_config, value):454 setenv = value455 config = testenv_config.config456 if "PYTHONHASHSEED" not in setenv and config.hashseed is not None:457 setenv["PYTHONHASHSEED"] = config.hashseed458 setenv["TOX_ENV_NAME"] = str(testenv_config.envname)459 setenv["TOX_ENV_DIR"] = str(testenv_config.envdir)460 return setenv461 parser.add_testenv_attribute(462 name="setenv",463 type="dict_setenv",464 postprocess=setenv,465 help="list of X=Y lines with environment variable settings",466 )467 def basepython_default(testenv_config, value):468 """either user set or proposed from the factor name469 in both cases we check that the factor name implied python version and the resolved470 python interpreter version match up; if they don't we warn, unless ignore base471 python conflict is set in which case the factor name implied version if forced472 """473 for factor in testenv_config.factors:474 if factor in tox.PYTHON.DEFAULT_FACTORS:475 implied_python = tox.PYTHON.DEFAULT_FACTORS[factor]476 break477 else:478 implied_python, factor = None, None479 if testenv_config.config.ignore_basepython_conflict and implied_python is not None:480 return implied_python481 proposed_python = (implied_python or sys.executable) if value is None else str(value)482 if implied_python is not None and implied_python != proposed_python:483 testenv_config.basepython = proposed_python484 implied_version = tox.PYTHON.PY_FACTORS_RE.match(factor).group(2)485 python_info_for_proposed = testenv_config.python_info486 if not isinstance(python_info_for_proposed, NoInterpreterInfo):487 proposed_version = "".join(488 str(i) for i in python_info_for_proposed.version_info[0:2]489 )490 if implied_version != proposed_version:491 # TODO(stephenfin): Raise an exception here in tox 4.0492 warnings.warn(493 "conflicting basepython version (set {}, should be {}) for env '{}';"494 "resolve conflict or set ignore_basepython_conflict".format(495 proposed_version, implied_version, testenv_config.envname496 )497 )498 return proposed_python499 parser.add_testenv_attribute(500 name="basepython",501 type="string",502 default=None,503 postprocess=basepython_default,504 help="executable name or path of interpreter used to create a virtual test environment.",505 )506 def merge_description(testenv_config, value):507 """the reader by default joins generated description with new line,508 replace new line with space"""509 return value.replace("\n", " ")510 parser.add_testenv_attribute(511 name="description",512 type="string",513 default="",514 postprocess=merge_description,515 help="short description of this environment",516 )517 parser.add_testenv_attribute(518 name="envtmpdir", type="path", default="{envdir}/tmp", help="venv temporary directory"519 )520 parser.add_testenv_attribute(521 name="envlogdir", type="path", default="{envdir}/log", help="venv log directory"522 )523 parser.add_testenv_attribute(524 name="downloadcache",525 type="string",526 default=None,527 help="(ignored) has no effect anymore, pip-8 uses local caching by default",528 )529 parser.add_testenv_attribute(530 name="changedir",531 type="path",532 default="{toxinidir}",533 help="directory to change to when running commands",534 )535 parser.add_testenv_attribute_obj(PosargsOption())536 parser.add_testenv_attribute(537 name="skip_install",538 type="bool",539 default=False,540 help="Do not install the current package. This can be used when you need the virtualenv "541 "management but do not want to install the current package",542 )543 parser.add_testenv_attribute(544 name="ignore_errors",545 type="bool",546 default=False,547 help="if set to True all commands will be executed irrespective of their result error "548 "status.",549 )550 def recreate(testenv_config, value):551 if testenv_config.config.option.recreate:552 return True553 return value554 parser.add_testenv_attribute(555 name="recreate",556 type="bool",557 default=False,558 postprocess=recreate,559 help="always recreate this test environment.",560 )561 def passenv(testenv_config, value):562 # Flatten the list to deal with space-separated values.563 value = list(itertools.chain.from_iterable([x.split(" ") for x in value]))564 passenv = {"PATH", "PIP_INDEX_URL", "LANG", "LANGUAGE", "LD_LIBRARY_PATH", "TOX_WORK_DIR"}565 # read in global passenv settings566 p = os.environ.get("TOX_TESTENV_PASSENV", None)567 if p is not None:568 env_values = [x for x in p.split() if x]569 value.extend(env_values)570 # we ensure that tmp directory settings are passed on571 # we could also set it to the per-venv "envtmpdir"572 # but this leads to very long paths when run with jenkins573 # so we just pass it on by default for now.574 if tox.INFO.IS_WIN:575 passenv.add("SYSTEMDRIVE") # needed for pip6576 passenv.add("SYSTEMROOT") # needed for python's crypto module577 passenv.add("PATHEXT") # needed for discovering executables578 passenv.add("COMSPEC") # needed for distutils cygwincompiler579 passenv.add("TEMP")580 passenv.add("TMP")581 # for `multiprocessing.cpu_count()` on Windows (prior to Python 3.4).582 passenv.add("NUMBER_OF_PROCESSORS")583 passenv.add("PROCESSOR_ARCHITECTURE") # platform.machine()584 passenv.add("USERPROFILE") # needed for `os.path.expanduser()`585 passenv.add("MSYSTEM") # fixes #429586 else:587 passenv.add("TMPDIR")588 for spec in value:589 for name in os.environ:590 if fnmatchcase(name.upper(), spec.upper()):591 passenv.add(name)592 return passenv593 parser.add_testenv_attribute(594 name="passenv",595 type="line-list",596 postprocess=passenv,597 help="environment variables needed during executing test commands (taken from invocation "598 "environment). Note that tox always passes through some basic environment variables "599 "which are needed for basic functioning of the Python system. See --showconfig for the "600 "eventual passenv setting.",601 )602 parser.add_testenv_attribute(603 name="whitelist_externals",604 type="line-list",605 help="each lines specifies a path or basename for which tox will not warn "606 "about it coming from outside the test environment.",607 )608 parser.add_testenv_attribute(609 name="platform",610 type="string",611 default=".*",612 help="regular expression which must match against ``sys.platform``. "613 "otherwise testenv will be skipped.",614 )615 def sitepackages(testenv_config, value):616 return testenv_config.config.option.sitepackages or value617 def alwayscopy(testenv_config, value):618 return testenv_config.config.option.alwayscopy or value619 parser.add_testenv_attribute(620 name="sitepackages",621 type="bool",622 default=False,623 postprocess=sitepackages,624 help="Set to ``True`` if you want to create virtual environments that also "625 "have access to globally installed packages.",626 )627 parser.add_testenv_attribute(628 name="alwayscopy",629 type="bool",630 default=False,631 postprocess=alwayscopy,632 help="Set to ``True`` if you want virtualenv to always copy files rather "633 "than symlinking.",634 )635 def pip_pre(testenv_config, value):636 return testenv_config.config.option.pre or value637 parser.add_testenv_attribute(638 name="pip_pre",639 type="bool",640 default=False,641 postprocess=pip_pre,642 help="If ``True``, adds ``--pre`` to the ``opts`` passed to the install command. ",643 )644 def develop(testenv_config, value):645 option = testenv_config.config.option646 return not option.installpkg and (value or option.develop)647 parser.add_testenv_attribute(648 name="usedevelop",649 type="bool",650 postprocess=develop,651 default=False,652 help="install package in develop/editable mode",653 )654 parser.add_testenv_attribute_obj(InstallcmdOption())655 parser.add_testenv_attribute(656 name="list_dependencies_command",657 type="argv",658 default="python -m pip freeze",659 help="list dependencies for a virtual environment",660 )661 parser.add_testenv_attribute_obj(DepOption())662 parser.add_testenv_attribute(663 name="commands",664 type="argvlist",665 default="",666 help="each line specifies a test command and can use substitution.",667 )668 parser.add_testenv_attribute(669 name="commands_pre",670 type="argvlist",671 default="",672 help="each line specifies a setup command action and can use substitution.",673 )674 parser.add_testenv_attribute(675 name="commands_post",676 type="argvlist",677 default="",678 help="each line specifies a teardown command and can use substitution.",679 )680 parser.add_testenv_attribute(681 "ignore_outcome",682 type="bool",683 default=False,684 help="if set to True a failing result of this testenv will not make "685 "tox fail, only a warning will be produced",686 )687 parser.add_testenv_attribute(688 "extras",689 type="line-list",690 help="list of extras to install with the source distribution or develop install",691 )692def cli_skip_missing_interpreter(parser):693 class SkipMissingInterpreterAction(argparse.Action):694 def __call__(self, parser, namespace, values, option_string=None):695 value = "true" if values is None else values696 if value not in ("config", "true", "false"):697 raise argparse.ArgumentTypeError("value must be config, true or false")698 setattr(namespace, self.dest, value)699 parser.add_argument(700 "--skip-missing-interpreters",701 default="config",702 metavar="val",703 nargs="?",704 action=SkipMissingInterpreterAction,705 help="don't fail tests for missing interpreters: {config,true,false} choice",706 )...

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