Skip to content

Commit

Permalink
add isolated test
Browse files Browse the repository at this point in the history
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Jan 18, 2020
1 parent 8b3132f commit 20a5019
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/unit/interpreters/create/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import six

from virtualenv.__main__ import run
from virtualenv.info import IS_PYPY
from virtualenv.info import IS_PYPY, IS_WIN
from virtualenv.interpreters.create.creator import DEBUG_SCRIPT, get_env_debug_info
from virtualenv.interpreters.discovery.builtin import get_interpreter
from virtualenv.interpreters.discovery.py_info import CURRENT, PythonInfo
Expand Down Expand Up @@ -77,11 +77,10 @@ def system():
return get_env_debug_info(Path(CURRENT.system_executable), DEBUG_SCRIPT)


@pytest.mark.parametrize("global_access", [False, True], ids=["no_global", "ok_global"])
@pytest.mark.parametrize(
"use_venv", [False, True] if six.PY3 else [False], ids=["no_venv", "venv"] if six.PY3 else ["no_venv"]
)
def test_create_no_seed(python, use_venv, global_access, system, coverage_env, special_name_dir):
@pytest.mark.parametrize("isolated", [True, False], ids=["isolated", "with_global_site"])
@pytest.mark.parametrize("method", (["copies"] + ([] if IS_WIN else ["symlinks"])))
@pytest.mark.parametrize("creator", (["builtin"] + (["venv"] if six.PY3 else [])))
def test_create_no_seed(python, creator, isolated, system, coverage_env, special_name_dir, method):
dest = special_name_dir
cmd = [
"-v",
Expand All @@ -93,9 +92,10 @@ def test_create_no_seed(python, use_venv, global_access, system, coverage_env, s
"--activators",
"",
"--creator",
"venv" if use_venv else "builtin",
creator,
"--{}".format(method),
]
if global_access:
if not isolated:
cmd.append("--system-site-packages")
result = run_via_cli(cmd)
coverage_env()
Expand Down Expand Up @@ -127,7 +127,9 @@ def test_create_no_seed(python, use_venv, global_access, system, coverage_env, s

# ensure the global site package is added or not, depending on flag
last_from_system_path = next(i for i in reversed(system_sys_path) if str(i).startswith(system["sys"]["prefix"]))
if global_access:
if isolated:
assert last_from_system_path not in sys_path
else:
common = []
for left, right in zip(reversed(system_sys_path), reversed(sys_path)):
if left == right:
Expand All @@ -139,8 +141,6 @@ def list_to_str(iterable):
return [six.ensure_text(str(i)) for i in iterable]

assert common, "\n".join(difflib.unified_diff(list_to_str(sys_path), list_to_str(system_sys_path)))
else:
assert last_from_system_path not in sys_path


@pytest.mark.skipif(not CURRENT.has_venv, reason="requires interpreter with venv")
Expand Down

0 comments on commit 20a5019

Please sign in to comment.