Skip to content
This repository has been archived by the owner on Jul 23, 2020. It is now read-only.

Commit

Permalink
Reapply tox-venv test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rpkilby committed Mar 28, 2019
1 parent d0639b2 commit ec1f605
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
22 changes: 17 additions & 5 deletions tests/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
VirtualEnv,
getdigest,
prepend_shebang_interpreter,
tox_testenv_create,
tox_testenv_install_deps,
)

from tox_venv.hooks import use_builtin_venv


def tox_testenv_create(action, venv):
return venv.hook.tox_testenv_create(action=action, venv=venv)


def test_getdigest(tmpdir):
assert getdigest(tmpdir) == "0" * 32
Expand Down Expand Up @@ -68,10 +73,16 @@ def test_create(mocksession, newconfig):
pcalls = mocksession._pcalls
assert len(pcalls) >= 1
args = pcalls[0].args
assert "virtualenv" == str(args[2])
module = "venv" if use_builtin_venv(venv) else "virtualenv"
assert module == str(args[2])
if not tox.INFO.IS_WIN:
executable = sys.executable
if use_builtin_venv(venv) and hasattr(sys, "real_prefix"):
# workaround virtualenv prefixing issue w/ venv on python3
executable = "python{}.{}".format(*sys.version_info)
executable = os.path.join(sys.real_prefix, "bin", executable)
# realpath is needed for stuff like the debian symlinks
our_sys_path = py.path.local(sys.executable).realpath()
our_sys_path = py.path.local(executable).realpath()
assert our_sys_path == py.path.local(args[0]).realpath()
# assert Envconfig.toxworkdir in args
assert venv.getcommandpath("easy_install", cwd=py.path.local())
Expand Down Expand Up @@ -446,7 +457,7 @@ def test_install_python3(newmocksession):
pcalls = mocksession._pcalls
assert len(pcalls) == 1
args = pcalls[0].args
assert str(args[2]) == "virtualenv"
assert str(args[2]) == "venv"
pcalls[:] = []
action = mocksession.newaction(venv, "hello")
venv._install(["hello"], action=action)
Expand Down Expand Up @@ -547,7 +558,8 @@ def test_python_recreation(self, tmpdir, newconfig, mocksession):
assert venv.path_config.check()
assert mocksession._pcalls
args1 = map(str, mocksession._pcalls[0].args)
assert "virtualenv" in " ".join(args1)
module = "venv" if use_builtin_venv(venv) else "virtualenv"
assert module in " ".join(args1)
mocksession.report.expect("*", "*create*")
# modify config and check that recreation happens
mocksession._clearmocks()
Expand Down
24 changes: 20 additions & 4 deletions tests/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from tox.config import parseconfig
from tox.session import Session

from tox_venv.hooks import use_builtin_venv

pytest_plugins = "pytester"


Expand Down Expand Up @@ -648,7 +650,7 @@ def _alwayscopy_not_supported():


@pytest.mark.skipif(alwayscopy_not_supported, reason="Platform doesnt support alwayscopy")
def test_alwayscopy(initproj, cmd):
def test_alwayscopy(initproj, cmd, mocksession):
initproj(
"example123",
filedefs={
Expand All @@ -659,12 +661,16 @@ def test_alwayscopy(initproj, cmd):
"""
},
)
venv = mocksession.getenv("python")
result = cmd("-vv")
assert not result.ret
assert "virtualenv --always-copy" in result.out
if use_builtin_venv(venv):
assert "venv --copies" not in result.out
else:
assert "virtualenv --always-copy" in result.out


def test_alwayscopy_default(initproj, cmd):
def test_alwayscopy_default(initproj, cmd, mocksession):
initproj(
"example123",
filedefs={
Expand All @@ -674,9 +680,13 @@ def test_alwayscopy_default(initproj, cmd):
"""
},
)
venv = mocksession.getenv("python")
result = cmd("-vv")
assert not result.ret
assert "virtualenv --always-copy" not in result.out
if use_builtin_venv(venv):
assert "venv --copies" not in result.out
else:
assert "virtualenv --always-copy" not in result.out


@pytest.mark.skipif("sys.platform == 'win32'")
Expand Down Expand Up @@ -816,6 +826,12 @@ def test_envsitepackagesdir_skip_missing_issue280(cmd, initproj):
def test_verbosity(cmd, initproj, verbosity):
initproj(
"pkgX-0.0.5",
# Note: This is related to https://github.com/tox-dev/tox#935
# For some reason, the .egg-info/ directory is interacting with the
# PYTHONPATH on Appveyor, causing the package to *not* be installed
# since pip already thinks it is. By setting the `src_root`, we can
# avoid the issue.
src_root="src",
filedefs={
"tox.ini": """
[testenv]
Expand Down

0 comments on commit ec1f605

Please sign in to comment.