How to use _getliveconfig method in tox

Best Python code snippet using tox_python

test_venv.py

Source:test_venv.py Github

copy

Full Screen

...69 # realpath is needed for stuff like the debian symlinks70 assert py.path.local(sys.executable).realpath() == args[i+1]71 #assert Envconfig.toxworkdir in args72 assert venv.getcommandpath("easy_install")73 interp = venv._getliveconfig().python74 assert interp == venv.getconfigexecutable()75def test_create_distribute(monkeypatch, mocksession, newconfig):76 config = newconfig([], """77 [testenv:py123]78 distribute=False79 """)80 envconfig = config.envconfigs['py123']81 venv = VirtualEnv(envconfig, session=mocksession)82 assert venv.path == envconfig.envdir83 assert not venv.path.check()84 venv.create()85 l = mocksession._pcalls86 assert len(l) >= 187 args = l[0].args88 assert "--distribute" not in " ".join(args)89def test_create_sitepackages(monkeypatch, mocksession, newconfig):90 config = newconfig([], """91 [testenv:site]92 sitepackages=True93 [testenv:nosite]94 sitepackages=False95 """)96 envconfig = config.envconfigs['site']97 venv = VirtualEnv(envconfig, session=mocksession)98 venv.create()99 l = mocksession._pcalls100 assert len(l) >= 1101 args = l[0].args102 assert "--no-site-packages" not in " ".join(args)103 mocksession._clearmocks()104 envconfig = config.envconfigs['nosite']105 venv = VirtualEnv(envconfig, session=mocksession)106 venv.create()107 l = mocksession._pcalls108 assert len(l) >= 1109 args = l[0].args110 assert "--no-site-packages" in " ".join(args)111@py.test.mark.skipif("sys.version_info[0] >= 3")112def test_install_downloadcache(newmocksession):113 mocksession = newmocksession([], """114 [testenv:py123]115 distribute=True116 deps=117 dep1118 dep2119 """)120 venv = mocksession.getenv("py123")121 venv.create()122 l = mocksession._pcalls123 assert len(l) == 1124 venv.install_deps()125 assert len(l) == 2126 args = l[1].args127 assert l[1].cwd == venv.envconfig.envlogdir128 assert "pip" in str(args[0])129 assert args[1] == "install"130 arg = "--download-cache=" + str(venv.envconfig.downloadcache)131 assert arg in args[2:]132 assert "dep1" in args133 assert "dep2" in args134 deps = filter(None, [x[1] for x in venv._getliveconfig().deps])135 assert deps == ['dep1', 'dep2']136def test_install_deps_indexserver(newmocksession):137 mocksession = newmocksession([], """138 [tox]139 indexserver =140 abc = ABC141 [testenv:py123]142 deps=143 dep1144 :abc:dep2145 """)146 venv = mocksession.getenv('py123')147 venv.create()148 l = mocksession._pcalls149 assert len(l) == 1150 l[:] = []151 venv.install_deps()152 # two different index servers, two calls153 assert len(l) == 2154 args = " ".join(l[0].args)155 assert "-i" not in args156 assert "dep1" in args157 args = " ".join(l[1].args)158 assert "-i ABC" in args159 assert "dep2" in args160def test_install_sdist_indexserver(newmocksession, tmpdir):161 mocksession = newmocksession([], """162 [tox]163 indexserver =164 default = ABC165 """)166 venv = mocksession.getenv('python')167 l = mocksession._pcalls168 p = tmpdir.ensure("distfile.tar.gz")169 venv.install_sdist(str(p))170 # two different index servers, two calls171 assert len(l) == 1172 args = " ".join(l[0].args)173 assert "-i ABC" in args174def test_install_recreate(newmocksession):175 mocksession = newmocksession(['--recreate'], """176 [testenv]177 deps=xyz178 """)179 venv = mocksession.getenv('python')180 venv.update()181 mocksession.report.expect("action", "*creating virtualenv*")182 venv.update()183 mocksession.report.expect("action", "recreating virtualenv*")184def test_install_error(newmocksession):185 mocksession = newmocksession(['--recreate'], """186 [testenv]187 deps=xyz188 commands=189 qwelkqw190 """)191 venv = mocksession.getenv('python')192 venv.test()193 mocksession.report.expect("error", "*not find*qwelkqw*")194def test_install_python3(tmpdir, newmocksession):195 if not py.path.local.sysfind('python3.1'):196 py.test.skip("needs python3.1")197 mocksession = newmocksession([], """198 [testenv:py123]199 basepython=python3.1200 deps=201 dep1202 dep2203 """)204 venv = mocksession.getenv('py123')205 venv.create()206 l = mocksession._pcalls207 assert len(l) == 1208 args = l[0].args209 assert 'virtualenv' in args[0]210 l[:] = []211 venv._install(["hello"])212 assert len(l) == 1213 args = l[0].args214 assert 'pip' in str(args[0])215 for x in args:216 assert "--download-cache" not in args, args217class TestCreationConfig:218 def test_basic(self, newconfig, mocksession, tmpdir):219 config = newconfig([], "")220 envconfig = config.envconfigs['python']221 venv = VirtualEnv(envconfig, session=mocksession)222 cconfig = venv._getliveconfig()223 assert cconfig.matches(cconfig)224 path = tmpdir.join("configdump")225 cconfig.writeconfig(path)226 newconfig = CreationConfig.readconfig(path)227 assert newconfig.matches(cconfig)228 assert cconfig.matches(newconfig)229 def test_matchingdependencies(self, newconfig, mocksession):230 config = newconfig([], """231 [testenv]232 deps=abc233 """)234 envconfig = config.envconfigs['python']235 venv = VirtualEnv(envconfig, session=mocksession)236 cconfig = venv._getliveconfig()237 config = newconfig([], """238 [testenv]239 deps=xyz240 """)241 envconfig = config.envconfigs['python']242 venv = VirtualEnv(envconfig, session=mocksession)243 otherconfig = venv._getliveconfig()244 assert not cconfig.matches(otherconfig)245 def test_matchingdependencies_file(self, newconfig, mocksession):246 config = newconfig([], """247 [tox]248 distshare={toxworkdir}/distshare249 [testenv]250 deps=abc251 {distshare}/xyz.zip252 """)253 xyz = config.distshare.join("xyz.zip")254 xyz.ensure()255 envconfig = config.envconfigs['python']256 venv = VirtualEnv(envconfig, session=mocksession)257 cconfig = venv._getliveconfig()258 assert cconfig.matches(cconfig)259 xyz.write("hello")260 newconfig = venv._getliveconfig()261 assert not cconfig.matches(newconfig)262 def test_matchingdependencies_latest(self, newconfig, mocksession):263 config = newconfig([], """264 [tox]265 distshare={toxworkdir}/distshare266 [testenv]267 deps={distshare}/xyz-*268 """)269 xyz = config.distshare.ensure("xyz-1.2.0.zip")270 xyz2 = config.distshare.ensure("xyz-1.2.1.zip")271 envconfig = config.envconfigs['python']272 venv = VirtualEnv(envconfig, session=mocksession)273 cconfig = venv._getliveconfig()274 md5, path = cconfig.deps[0]275 assert path == xyz2276 assert md5 == path.computehash()277 def test_python_recreation(self, newconfig, mocksession):278 config = newconfig([], "")279 envconfig = config.envconfigs['python']280 venv = VirtualEnv(envconfig, session=mocksession)281 cconfig = venv._getliveconfig()282 venv.update()283 assert mocksession._pcalls284 args1 = mocksession._pcalls[0].args285 assert 'virtualenv' in " ".join(args1)286 mocksession.report.expect("action", "creating virtualenv*")287 # modify config and check that recreation happens288 mocksession._clearmocks()289 venv.update()290 mocksession.report.expect("action", "reusing existing*")291 mocksession._clearmocks()292 cconfig.python = py.path.local("balla")293 cconfig.writeconfig(venv.path_config)294 venv.update()295 mocksession.report.expect("action", "recreating virtualenv*")296 def test_dep_recreation(self, newconfig, mocksession):297 config = newconfig([], "")298 envconfig = config.envconfigs['python']299 venv = VirtualEnv(envconfig, session=mocksession)300 venv.update()301 cconfig = venv._getliveconfig()302 cconfig.deps[:] = [("1"*32, "xyz.zip")]303 cconfig.writeconfig(venv.path_config)304 mocksession._clearmocks()305 venv.update()306 mocksession.report.expect("action", "recreating virtualenv*")307 def test_distribute_recreation(self, newconfig, mocksession):308 config = newconfig([], "")309 envconfig = config.envconfigs['python']310 venv = VirtualEnv(envconfig, session=mocksession)311 venv.update()312 cconfig = venv._getliveconfig()313 cconfig.distribute = False314 cconfig.writeconfig(venv.path_config)315 mocksession._clearmocks()316 venv.update()317 mocksession.report.expect("action", "recreating virtualenv*")318class TestVenvTest:319 def test_patchPATH(self, newmocksession, monkeypatch):320 mocksession = newmocksession([], """321 [testenv:python]322 commands=abc323 """)324 venv = mocksession.getenv("python")325 envconfig = venv.envconfig326 monkeypatch.setenv("PATH", "xyz")...

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