Best Python code snippet using tox_python
test_tox_python_executable.py
Source:test_tox_python_executable.py
...6 self.basepython = basepython7class TestToxGetPythonExecutable:8 @pytest.mark.asdf_missing9 def test_asdf_missing(self, asdf, LOG):10 python = plugin.tox_get_python_executable(EnvConfig())11 assert python is None12 LOG.error.assert_called_once()13 @pytest.mark.asdf_python_missing14 def test_asdf_python_plugin_missing(self, asdf, LOG):15 python = plugin.tox_get_python_executable(EnvConfig())16 assert python is None17 LOG.error.assert_called_once()18 @pytest.mark.asdf_error(42, "Unknown error")19 def test_asdf_unknown_error(self, asdf, LOG):20 python = plugin.tox_get_python_executable(EnvConfig())21 assert python is None22 LOG.error.assert_called_once()23 @pytest.mark.asdf_error("list", 42, "Unknown error")24 def test_asdf_list_error(self, asdf, LOG):25 python = plugin.tox_get_python_executable(EnvConfig())26 assert python is None27 LOG.error.assert_called_once()28 @pytest.mark.pythons("3.6.0")29 @pytest.mark.asdf_error("where", 42, "Unknown error")30 def test_asdf_where_error(self, asdf, LOG):31 python = plugin.tox_get_python_executable(EnvConfig())32 assert python is None33 LOG.error.assert_called_once()34 def test_basepython_is_not_python(self):35 envconfig = EnvConfig("*TEST*")36 python = plugin.tox_get_python_executable(envconfig)37 assert python is None38 def test_return_none_if_no_python(self, asdf):39 assert plugin.tox_get_python_executable(EnvConfig()) is None40 @pytest.mark.all_pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")41 def test_install_python_if_no_python_but_flag(self, asdf, CFG):42 CFG.install = True43 python = plugin.tox_get_python_executable(EnvConfig())44 assert python == asdf.python_bin("3.6.0")45 @pytest.mark.all_pythons("2.7.15", "pypy2.7-6.0.0", "pypy3.8-7.0.0")46 def test_install_python_but_return_none_if_no_match(self, asdf, CFG):47 CFG.install = True48 assert plugin.tox_get_python_executable(EnvConfig()) is None49 @pytest.mark.pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")50 def test_return_python_binary_path(self, asdf):51 python = plugin.tox_get_python_executable(EnvConfig())52 assert python == asdf.python_bin("3.6.0")53 @pytest.mark.pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")54 def test_return_pypy_python_binary_path(self, asdf):55 envconfig = EnvConfig("pypy")56 python = plugin.tox_get_python_executable(envconfig)57 assert python == asdf.python_bin("pypy2.7-6.0.0")58 @pytest.mark.pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")59 def test_return_pypy3_python_binary_path(self, asdf):60 envconfig = EnvConfig("pypy3")61 python = plugin.tox_get_python_executable(envconfig)62 assert python == asdf.python_bin("pypy3.8-7.0.0")63class TestToxGetPythonExecutableNoFallback:64 @pytest.fixture(autouse=True)65 def set_no_fallback(self, CFG):66 CFG.no_fallback = True67 @pytest.mark.asdf_missing68 def test_asdf_missing(self, asdf, LOG):69 with pytest.raises(plugin.AsdfError):70 plugin.tox_get_python_executable(EnvConfig())71 LOG.error.assert_called_once()72 @pytest.mark.asdf_python_missing73 def test_asdf_python_plugin_missing(self, asdf, LOG):74 with pytest.raises(plugin.AsdfError):75 plugin.tox_get_python_executable(EnvConfig())76 LOG.error.assert_called_once()77 @pytest.mark.asdf_error(42, "Unknown error")78 def test_asdf_unknown_error(self, asdf, LOG):79 with pytest.raises(plugin.AsdfError):80 plugin.tox_get_python_executable(EnvConfig())81 LOG.error.assert_called_once()82 @pytest.mark.asdf_error("list", 42, "Unknown error")83 def test_asdf_list_error(self, asdf, LOG):84 with pytest.raises(plugin.AsdfError):85 plugin.tox_get_python_executable(EnvConfig())86 LOG.error.assert_called_once()87 @pytest.mark.pythons("3.6.0")88 @pytest.mark.asdf_error("where", 42, "Unknown error")89 def test_asdf_which_error(self, asdf, LOG):90 with pytest.raises(plugin.AsdfError):91 plugin.tox_get_python_executable(EnvConfig())92 LOG.error.assert_called_once()93 def test_basepython_is_not_python(self):94 envconfig = EnvConfig("*TEST*")95 assert plugin.tox_get_python_executable(envconfig) is None96 def test_raise_if_no_python(self, asdf):97 with pytest.raises(plugin.AsdfError):98 plugin.tox_get_python_executable(EnvConfig())99 @pytest.mark.all_pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")100 def test_install_python_if_no_python_but_flag(self, asdf, CFG):101 CFG.install = True102 python = plugin.tox_get_python_executable(EnvConfig())103 assert python == asdf.python_bin("3.6.0")104 @pytest.mark.all_pythons("2.7.15", "pypy2.7-6.0.0", "pypy3.8-7.0.0")105 def test_install_python_but_raise_if_no_match(self, asdf, CFG):106 CFG.install = True107 with pytest.raises(plugin.AsdfError):108 plugin.tox_get_python_executable(EnvConfig())109 @pytest.mark.pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")110 def test_return_python_binary_path(self, asdf):111 python = plugin.tox_get_python_executable(EnvConfig())112 assert python == asdf.python_bin("3.6.0")113 @pytest.mark.pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")114 def test_return_pypy_python_binary_path(self, asdf):115 envconfig = EnvConfig("pypy")116 python = plugin.tox_get_python_executable(envconfig)117 assert python == asdf.python_bin("pypy2.7-6.0.0")118 @pytest.mark.pythons("2.7.15", "3.6.0", "pypy2.7-6.0.0", "pypy3.8-7.0.0")119 def test_return_pypy3_python_binary_path(self, asdf):120 envconfig = EnvConfig("pypy3")121 python = plugin.tox_get_python_executable(envconfig)...
__init__.py
Source:__init__.py
...17 """18 try:19 return self.name2executable[envconfig.envname]20 except KeyError:21 exe = self.hook.tox_get_python_executable(envconfig=envconfig)22 reporter.verbosity2("{} uses {}".format(envconfig.envname, exe))23 self.name2executable[envconfig.envname] = exe24 return exe25 def get_info(self, envconfig):26 executable = self.get_executable(envconfig)27 name = envconfig.basepython28 if not executable:29 return NoInterpreterInfo(name=name)30 try:31 return self.executable2info[executable]32 except KeyError:33 info = run_and_get_interpreter_info(name, executable)34 self.executable2info[executable] = info35 return info...
toxhooks.py
Source:toxhooks.py
...26 envConf.setenv[envConf.randpwdenv] = pwd27def gen_rand_pwd(size=10, chars=string.ascii_letters + string.digits):28 return ''.join(random.choice(chars) for _ in range(size))29@hookimpl30def tox_get_python_executable(envconfig):31 print("In local tox_get_python_executable hook")32 os.environ['LOCAL_PLUGIN_GET_PYTHON_EXECUTABLE'] = 'local_get_python_executable'33@hookimpl34def tox_runenvreport(venv, action):35 print("In local tox_runenvreport")...
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!!