How to use get_envbindir method in tox

Best Python code snippet using tox_python

config.py

Source:config.py Github

copy

Full Screen

...501 self.config = config502 #: set of factors503 self.factors = factors504 self._reader = reader505 def get_envbindir(self):506 """ path to directory where scripts/binaries reside. """507 if (sys.platform == "win32"508 and "jython" not in self.basepython509 and "pypy" not in self.basepython):510 return self.envdir.join("Scripts")511 else:512 return self.envdir.join("bin")513 @property514 def envbindir(self):515 return self.get_envbindir()516 @property517 def envpython(self):518 """ path to python executable. """519 return self.get_envpython()520 def get_envpython(self):521 """ path to python/jython executable. """522 if "jython" in str(self.basepython):523 name = "jython"524 else:525 name = "python"526 return self.envbindir.join(name)527 def get_envsitepackagesdir(self):528 """ return sitepackagesdir of the virtualenv environment.529 (only available during execution, not parsing)...

Full Screen

Full Screen

test_tox_direct.py

Source:test_tox_direct.py Github

copy

Full Screen

...69 assert direct.deps == []70 assert direct.skip_install is True71 assert direct.basepython == sys.executable72 assert direct.envpython == sys.executable73 assert direct.get_envbindir() == str(Path(sys.executable).parent)74def test_does_not_interfere_with_single_normal_env(cmd, initproj):75 initproj(76 "does_not_interfer_with_normal_operation",77 filedefs={78 "tox.ini": """79 [testenv:normal]80 deps = decorator81 commands = 82 pip list83 python -c 'import sys; print(sys.executable);'84 """85 },86 )87 r = cmd()...

Full Screen

Full Screen

hookimpls.py

Source:hookimpls.py Github

copy

Full Screen

1from __future__ import print_function2import os3import sys4import py5import tox6from tox.session import reporter7from tox.exception import Error8class DIRECT:9 MARKER = "direct"10 ENV_VAR = "TOX_DIRECT"11 ENV_VAR_YOLO = "TOX_DIRECT_YOLO"12 SKIPSDIST_ORIGINAL = "_TOX_DIRECT_SKIPSDIST_ORIGINAL"13 PYTHON = py.path.local(sys.executable)14@tox.hookimpl15def tox_addoption(parser):16 # necessary to allow the direct= directives in testenv sections17 parser.add_testenv_attribute(18 name="direct",19 type="bool",20 help="[tox-direct] deactivate venv, packaging and install steps - "21 "run commands directly ",22 default=False,23 )24 parser.add_argument(25 "--direct",26 action="store_true",27 help="[tox-direct] deactivate venv, packaging and install steps - "28 "run commands directly "29 "(can also be achieved by setting {})".format(DIRECT.ENV_VAR),30 )31 parser.add_argument(32 "--direct-yolo",33 action="store_true",34 help="[tox-direct] do everything in host environment that would otherwise "35 "happen in an isolated virtual environment (can also be achieved "36 "by setting {} env var".format(DIRECT.ENV_VAR_YOLO),37 )38@tox.hookimpl39def tox_configure(config):40 if DIRECT.ENV_VAR in os.environ:41 config.option.direct = True42 if DIRECT.ENV_VAR_YOLO in os.environ:43 config.option.direct_yolo = True44 YOLO = config.option.direct_yolo45 if is_direct_run(config):46 if YOLO:47 reporter.info("YOLO! Do everything in the host environment.")48 setattr(config, DIRECT.SKIPSDIST_ORIGINAL, config.skipsdist)49 if not config.skipsdist and not YOLO:50 reporter.info("[tox-direct] won't build a package")51 config.skipsdist = True52 for name, envconfig in config.envconfigs.items():53 if not is_direct_call(config) and not is_direct_env(name, envconfig):54 continue55 # TODO this could also be basepython on request (needed?)56 envconfig.get_envbindir = lambda: py.path.local(DIRECT.PYTHON.dirname)57 envconfig.get_envpython = lambda: py.path.local(DIRECT.PYTHON)58 assert envconfig.envpython == DIRECT.PYTHON, envconfig.envpython59 if envconfig.deps and not YOLO:60 reporter.info(61 "[tox-direct] won't install dependencies in '{}'".format(name)62 )63 envconfig.deps = []64 if not envconfig.skip_install and not YOLO:65 envconfig.skip_install = True66 reporter.info("[tox-direct] won't install project in {}".format(name))67@tox.hookimpl68def tox_testenv_create(venv):69 if not is_direct_run(venv.envconfig.config):70 return # normal behaviour71 isDirectCall = is_direct_call(venv.envconfig.config)72 isDirectEnv = is_direct_env(venv.name, venv.envconfig)73 YOLO = venv.envconfig.config.option.direct_yolo74 if not isDirectEnv and not YOLO:75 # direct run only safe for "normal" env if package not used in testenv76 needsPackage = (77 not venv.envconfig.skip_install78 and not venv.envconfig.usedevelop79 )80 if needsPackage and not getattr(venv.envconfig.config, DIRECT.SKIPSDIST_ORIGINAL):81 raise NormalEnvNeedsPackage(82 "[tox-direct] FATAL: tox env '{}' needs a package.\n"83 "Do not run this env as part of a direct run or "84 "run everything in the host (including package build) by running "85 "with --direct-yolo flag.\n"86 "WARNING: this will change the host environment.".format(venv.name)87 )88 if isDirectCall or isDirectEnv:89 venv.is_allowed_external = lambda _: True # everything goes!90 reporter.info(91 "[tox-direct] creating no virtual environment - use:"92 " {}".format(venv.envconfig.envpython)93 )94 if not YOLO:95 return True96 reporter.info("[tox-direct] YOLO!1!!")97def is_direct_run(config):98 return is_direct_call(config) or has_direct_envs(config.envconfigs)99def is_direct_call(config):100 return config.option.direct or config.option.direct_yolo101def has_direct_envs(envconfigs):102 return any(is_direct_env(envname, envconfig) for envname, envconfig in envconfigs.items() )103def is_direct_env(envname, envconfig):104 return DIRECT.MARKER in envname or envconfig.direct105class NormalEnvNeedsPackage(Error):...

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