Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_test_env(config, mocksession, envname):
venv = VirtualEnv(config.envconfigs[envname])
action = mocksession.newaction(venv, "getenv")
tox_testenv_create(action=action, venv=venv)
pcalls = mocksession._pcalls
assert len(pcalls) == 1
pcalls[:] = []
return venv, action, pcalls
def test_conda_create(newconfig, mocksession):
config = newconfig(
[],
"""
[testenv:py123]
""",
)
venv = VirtualEnv(config.envconfigs["py123"])
assert venv.path == config.envconfigs["py123"].envdir
action = mocksession.newaction(venv, "getenv")
tox_testenv_create(action=action, venv=venv)
pcalls = mocksession._pcalls
assert len(pcalls) == 1
assert "conda" in pcalls[0].args[0]
assert "create" == pcalls[0].args[1]
assert "--yes" == pcalls[0].args[2]
assert "-p" == pcalls[0].args[3]
assert venv.path == pcalls[0].args[4]
assert pcalls[0].args[5].startswith("python=")
def tox_testenv_create(self, action, venv):
assert isinstance(action, tox.session.Action)
assert isinstance(venv, VirtualEnv)
log.append(1)
def tox_testenv_install_deps(self, action, venv):
assert isinstance(action, tox.session.Action)
assert isinstance(venv, VirtualEnv)
log.append(2)
def _makevenv(self, name):
envconfig = self.config.envconfigs.get(name, None)
if envconfig is None:
self.report.error("unknown environment {!r}".format(name))
raise LookupError(name)
elif envconfig.envdir == self.config.toxinidir:
self.report.error(
"venv {!r} in {} would delete project".format(name, envconfig.envdir)
)
raise tox.exception.ConfigError("envdir must not equal toxinidir")
venv = VirtualEnv(envconfig=envconfig, session=self)
self._name2venv[name] = venv
return venv
def getvenv(self, name):
if name in self.existing_venvs:
return self.existing_venvs[name]
env_config = self.config.envconfigs.get(name, None)
if env_config is None:
reporter.error("unknown environment {!r}".format(name))
raise LookupError(name)
elif env_config.envdir == self.config.toxinidir:
reporter.error("venv {!r} in {} would delete project".format(name, env_config.envdir))
raise tox.exception.ConfigError("envdir must not equal toxinidir")
env_log = self.resultlog.get_envlog(name)
venv = VirtualEnv(envconfig=env_config, popen=self.popen, env_log=env_log)
self.existing_venvs[name] = venv
return venv