How to use basepython_default method in tox

Best Python code snippet using tox_python

config.py

Source:config.py Github

copy

Full Screen

...273 # add various core venv interpreter attributes274 parser.add_testenv_attribute(275 name="envdir", type="path", default="{toxworkdir}/{envname}",276 help="venv directory")277 def basepython_default(testenv_config, value):278 if value is None:279 for f in testenv_config.factors:280 if f in default_factors:281 return default_factors[f]282 return sys.executable283 return str(value)284 parser.add_testenv_attribute(285 name="basepython", type="string", default=None, postprocess=basepython_default,286 help="executable name or path of interpreter used to create a "287 "virtual test environment.")288 parser.add_testenv_attribute(289 name="envtmpdir", type="path", default="{envdir}/tmp",290 help="venv temporary directory")291 parser.add_testenv_attribute(...

Full Screen

Full Screen

version_utils.py

Source:version_utils.py Github

copy

Full Screen

1import re2import sys3from tox.interpreters import InterpreterInfo4# tox sets TestenvConfig.basepython to sys.executable5# if the testenv doesn't ask for something more specific.6TOX_DEFAULT_BASEPYTHON = sys.executable7def basepython_to_gh_python_version(basepython: str) -> str:8 """9 Map a tox TestenvConfig basepython string to a10 GitHub actions/setup-python python-version string.11 E.g.: "python3.10" --> "3.10" or "pypy3.8" --> "pypy-3.8"12 """13 # (See `basepython_default` in tox.config for potential values14 # of basepython, from tox factors like py310 or pypy38.)15 # ??? Maybe use tox.interpreters.py_spec.PythonSpec.from_name instead?16 if basepython == TOX_DEFAULT_BASEPYTHON:17 return ""18 match = re.fullmatch(r"(python|pypy|jython)(\d+(\.\d+)?)?", basepython)19 if not match:20 raise ValueError(f"Unexpected basepython format {basepython!r}")21 implementation = match[1]22 version = match[2] or ""23 if implementation == "python":24 return version25 elif version:26 return f"{implementation}-{version}"27 else:28 return implementation29def python_version_to_prerelease_spec(python: str) -> str:30 """31 Expand a python-version string to allow prerelease Python,32 using SemVer ranges. (Doesn't currently handle pypy.)33 >>> python_version_to_prerelease_spec("3.7")34 '3.7.0-alpha - 3.7'35 Only handles tox-factor-generated N.M versions36 (not N and not N.M.P):37 >>> python_version_to_prerelease_spec("3")38 '3'39 >>> python_version_to_prerelease_spec("3.5.7")40 '3.5.7'41 """42 match = re.fullmatch(r"^(|pypy-|jython-)(\d+\.\d+)$", python)43 if match:44 implementation = match[1]45 version = match[2]46 if implementation == "":47 python = f"{implementation}{version}.0-alpha - {version}"48 return python49def interpreter_info_to_version(python_info: InterpreterInfo) -> str:50 """Format a GH python-version string from tox InterpreterInfo"""51 version = format_version_info(python_info.version_info)52 if python_info.extra_version_info:53 extra_version = format_version_info(python_info.extra_version_info)54 version = f"{version}-{extra_version}"55 implementation = python_info.implementation.lower()56 if implementation != "cpython":57 version = f"{implementation}-{version}"58 return version59def format_version_info(version_info: (int, int, int, str, int)) -> str:60 """Format a sys.version_info-style Python version tuple to a string"""61 (major, minor, micro, releaselevel, serial) = version_info62 version = f"{major}.{minor}.{micro}"63 if releaselevel != "final" or serial != 0:64 version += f"-{releaselevel}.{serial}"...

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