Best Python code snippet using tox_python
plugin.py
Source:plugin.py
...19def tox_configure(config):20 # type: (Config) -> None21 verbosity1("running tox-gh-actions")22 if is_running_on_container():23 verbosity2(24 "not enabling problem matcher as tox seems to be running on a container"25 )26 # Trying to add a problem matcher from a container without proper host mount can27 # cause an error like the following:28 # Unable to process command '::add-matcher::/.../matcher.json' successfully.29 else:30 verbosity2("enabling problem matcher")31 print("::add-matcher::" + get_problem_matcher_file_path())32 if not is_log_grouping_enabled(config):33 verbosity2(34 "disabling log line grouping on GitHub Actions based on the configuration"35 )36 if not is_running_on_actions():37 verbosity1(38 "tox-gh-actions won't override envlist "39 "because tox is not running in GitHub Actions"40 )41 return42 elif is_env_specified(config):43 verbosity1(44 "tox-gh-actions won't override envlist because "45 "envlist is explicitly given via TOXENV or -e option"46 )47 return48 verbosity2("original envconfigs: {}".format(list(config.envconfigs.keys())))49 verbosity2("original envlist_default: {}".format(config.envlist_default))50 verbosity2("original envlist: {}".format(config.envlist))51 versions = get_python_version_keys()52 verbosity2("Python versions: {}".format(versions))53 gh_actions_config = parse_config(config._cfg.sections)54 verbosity2("tox-gh-actions config: {}".format(gh_actions_config))55 factors = get_factors(gh_actions_config, versions)56 verbosity2("using the following factors to decide envlist: {}".format(factors))57 envlist = get_envlist_from_factors(config.envlist, factors)58 config.envlist_default = config.envlist = envlist59 if len(envlist) == 0:60 warning(61 "tox-gh-actions couldn't find environments matching the provided factors "62 "from envlist. Please use `tox -vv` to get more detailed logs."63 )64 verbosity1("overriding envlist with: {}".format(envlist))65@hookimpl66def tox_testenv_create(venv, action):67 # type: (VirtualEnv, Action) -> None68 if is_log_grouping_enabled(venv.envconfig.config):69 start_grouping_if_necessary(venv)70@hookimpl71def tox_testenv_install_deps(venv, action):72 # type: (VirtualEnv, Action) -> None73 if is_log_grouping_enabled(venv.envconfig.config):74 start_grouping_if_necessary(venv)75@hookimpl76def tox_runtest_pre(venv):77 # type: (VirtualEnv) -> None78 if is_log_grouping_enabled(venv.envconfig.config):79 start_grouping_if_necessary(venv)80@hookimpl81def tox_runtest_post(venv):82 # type: (VirtualEnv) -> None83 if is_log_grouping_enabled(venv.envconfig.config):84 print("::endgroup::")85@hookimpl86def tox_cleanup(session):87 # This hook can be called multiple times especially when using parallel mode88 if not is_running_on_actions():89 return90 verbosity2("disabling problem matcher")91 for owner in get_problem_matcher_owners():92 print("::remove-matcher owner={}::".format(owner))93def start_grouping_if_necessary(venv):94 # type: (VirtualEnv) -> None95 """Start log line grouping when necessary.96 This function can be called multiple times when running a test environment97 and it ensures that "::group::" is written only once.98 We shouldn't call this from tox_package and tox_get_python_executable hooks99 because of the timing issue.100 """101 envconfig = venv.envconfig # type: TestenvConfig102 envname = envconfig.envname103 # Do not enable grouping for an environment used for isolated build104 # because we don't have a hook to write "::endgroup::" for this environment.105 # TODO Make sure the exact condition when isolated_build_env is not set106 if envname == getattr(envconfig.config, "isolated_build_env", ""):107 return108 if thread_locals.is_grouping_started.get(envname, False):109 return110 thread_locals.is_grouping_started[envname] = True111 message = envname112 if envconfig.description:113 message += " - " + envconfig.description114 print("::group::tox: " + message)115def parse_config(config):116 # type: (Dict[str, Dict[str, str]]) -> Dict[str, Dict[str, Any]]117 """Parse gh-actions section in tox.ini"""118 config_python = parse_dict(config.get("gh-actions", {}).get("python", ""))119 config_env = {120 name: {k: split_env(v) for k, v in parse_dict(conf).items()}121 for name, conf in config.get("gh-actions:env", {}).items()122 }123 # Example of split_env:124 # "py{27,38}" => ["py27", "py38"]125 return {126 "python": {k: split_env(v) for k, v in config_python.items()},127 "env": config_env,128 }129def get_factors(gh_actions_config, versions):130 # type: (Dict[str, Dict[str, Any]], Iterable[str]) -> List[str]131 """Get a list of factors"""132 factors = [] # type: List[List[str]]133 for version in versions:134 if version in gh_actions_config["python"]:135 show_deprecation_warning_for_old_style_pypy_config(version)136 verbosity2("got factors for Python version: {}".format(version))137 factors.append(gh_actions_config["python"][version])138 break # Shouldn't check remaining versions139 for env, env_config in gh_actions_config.get("env", {}).items():140 if env in os.environ:141 env_value = os.environ[env]142 if env_value in env_config:143 factors.append(env_config[env_value])144 return [x for x in map(lambda f: "-".join(f), product(*factors)) if x]145def show_deprecation_warning_for_old_style_pypy_config(version):146 # type: (str) -> None147 if version not in {"pypy2", "pypy3"}:148 return149 warning(150 """PendingDeprecationWarning...
__init__.py
Source:__init__.py
...61 # Only run if we're enabled62 toxinidir = str(config.toxinidir)63 cfg = get_config(toxinidir)64 if "wikimedia" not in cfg:65 verbosity2("[wikimedia] tox-wikimedia is not enabled, skipping")66 return67 verbosity2("[wikimedia] tox-wikimedia is enabled")68 for envname, econfig in config.envconfigs.items():69 for factor in econfig.factors:70 # factors are py35, flake8, pytest, etc.71 try:72 fconfig = TOOLS[factor] # type: dict73 except KeyError:74 continue75 for dep in fconfig["deps"]:76 # Check to make sure the dep is not already77 # specific (e.g. to specify a constraint)78 for cdep in econfig.deps:79 if dep in cdep.name:80 break81 else:82 econfig.deps.append(DepConfig(dep))83 verbosity2(84 "[wikimedia] {}: Adding dep on {}".format(envname, dep)85 )86 if fconfig.get("requirements"):87 for txtdep in [88 "requirements.txt",89 "test-requirements.txt",90 ]:91 if os.path.exists(os.path.join(toxinidir, txtdep)):92 verbosity2(93 "[wikimedia] {}: Adding dep on {}".format(94 envname, txtdep95 )96 )97 econfig.deps.append(DepConfig("-r{}".format(txtdep)))98 if econfig.commands:99 verbosity2(100 "[wikimedia] {}: overridden commands: {}".format(101 envname, repr(econfig.commands)102 )103 )104 if not econfig.commands:105 # If there's no command, then set one106 cmd = []107 for part in fconfig["commands"]:108 if "{" in part:109 # Needs formatting110 part = part.format(**cfg["wikimedia"])111 cmd.append(part)112 econfig.commands.append(cmd)113 verbosity2(114 "[wikimedia] {}: Setting command to {}".format(115 envname, str(cmd)116 )117 )118 if not econfig.description:...
test_auto_SVReg.py
Source:test_auto_SVReg.py
1# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT2from ..brainsuite import SVReg3def test_SVReg_inputs():4 input_map = dict(5 args=dict(6 argstr="%s",7 ),8 atlasFilePrefix=dict(9 argstr="'%s'",10 position=1,11 ),12 curveMatchingInstructions=dict(13 argstr="'-cur %s'",14 ),15 dataSinkDelay=dict(16 argstr="%s",17 ),18 displayModuleName=dict(19 argstr="'-m'",20 ),21 displayTimestamps=dict(22 argstr="'-t'",23 ),24 environ=dict(25 nohash=True,26 usedefault=True,27 ),28 iterations=dict(29 argstr="'-H %d'",30 ),31 keepIntermediates=dict(32 argstr="'-k'",33 ),34 pialSurfaceMaskDilation=dict(35 argstr="'-D %d'",36 ),37 refineOutputs=dict(38 argstr="'-r'",39 ),40 shortMessages=dict(41 argstr="'-gui'",42 ),43 skipToIntensityReg=dict(44 argstr="'-p'",45 ),46 skipToVolumeReg=dict(47 argstr="'-s'",48 ),49 skipVolumetricProcessing=dict(50 argstr="'-S'",51 ),52 subjectFilePrefix=dict(53 argstr="'%s'",54 mandatory=True,55 position=0,56 ),57 useCerebrumMask=dict(58 argstr="'-C'",59 ),60 useManualMaskFile=dict(61 argstr="'-cbm'",62 ),63 useMultiThreading=dict(64 argstr="'-P'",65 ),66 useSingleThreading=dict(67 argstr="'-U'",68 ),69 verbosity0=dict(70 argstr="'-v0'",71 xor=("verbosity0", "verbosity1", "verbosity2"),72 ),73 verbosity1=dict(74 argstr="'-v1'",75 xor=("verbosity0", "verbosity1", "verbosity2"),76 ),77 verbosity2=dict(78 argstr="'v2'",79 xor=("verbosity0", "verbosity1", "verbosity2"),80 ),81 )82 inputs = SVReg.input_spec()83 for key, metadata in list(input_map.items()):84 for metakey, value in list(metadata.items()):...
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!!