Best Python code snippet using tox_python
test_interpreters.py
Source:test_interpreters.py
...33 envconfig.basepython = name34 p = tox_get_python_executable(envconfig)35 assert p36 return str(p)37 def assert_version_in_output(exe, version):38 out = subprocess.check_output((exe, "-V"), stderr=subprocess.STDOUT)39 assert version in out.decode()40 p = tox_get_python_executable(envconfig)41 assert p == py.path.local(sys.executable)42 for major, minor in [(2, 7), (3, 5), (3, 6), (3, 7), (3, 8)]:43 name = "python{}.{}".format(major, minor)44 if tox.INFO.IS_WIN:45 pydir = "python{}{}".format(major, minor)46 x = py.path.local(r"c:\{}".format(pydir))47 if not x.check():48 continue49 else:50 if not py.path.local.sysfind(name) or subprocess.call((name, "-c", "")):51 continue52 exe = get_exe(name)53 assert_version_in_output(exe, "{}.{}".format(major, minor))54 has_py_exe = py.path.local.sysfind("py") is not None55 for major in (2, 3):56 name = "python{}".format(major)57 if has_py_exe:58 error_code = subprocess.call(("py", "-{}".format(major), "-c", ""))59 if error_code:60 continue61 elif not py.path.local.sysfind(name):62 continue63 exe = get_exe(name)64 assert_version_in_output(exe, str(major))65@pytest.mark.skipif("sys.platform == 'win32'", reason="symlink execution unreliable on Windows")66def test_find_alias_on_path(monkeypatch, tmp_path, mocker):67 reporter.update_default_reporter(Verbosity.DEFAULT, Verbosity.DEBUG)68 magic = tmp_path / "magic{}".format(os.path.splitext(sys.executable)[1])69 os.symlink(sys.executable, str(magic))70 monkeypatch.setenv(71 str("PATH"),72 os.pathsep.join([str(tmp_path)] + os.environ.get(str("PATH"), "").split(os.pathsep)),73 )74 class envconfig:75 basepython = "magic"76 envname = "pyxx"77 config = mocker.MagicMock()78 config.return_value.option.return_value.discover = []...
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!!