summaryrefslogtreecommitdiff
path: root/tests/unit/create/test_creator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/create/test_creator.py')
-rw-r--r--tests/unit/create/test_creator.py85
1 files changed, 3 insertions, 82 deletions
diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
index ea61ed0..1f3750f 100644
--- a/tests/unit/create/test_creator.py
+++ b/tests/unit/create/test_creator.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import ast
import difflib
import gc
@@ -22,9 +24,7 @@ import pytest
from virtualenv.__main__ import run, run_with_catch
from virtualenv.create.creator import DEBUG_SCRIPT, Creator, get_env_debug_info
from virtualenv.create.pyenv_cfg import PyEnvCfg
-from virtualenv.create.via_global_ref.builtin.cpython.cpython2 import CPython2PosixBase
from virtualenv.create.via_global_ref.builtin.cpython.cpython3 import CPython3Posix
-from virtualenv.create.via_global_ref.builtin.python2.python2 import Python2
from virtualenv.discovery.py_info import PythonInfo
from virtualenv.info import IS_PYPY, IS_WIN, fs_is_case_sensitive
from virtualenv.run import cli_run, session_via_cli
@@ -101,29 +101,11 @@ for k, v in CURRENT.creators().key_to_meta.items():
CREATE_METHODS.append((k, "copies"))
if v.can_symlink:
CREATE_METHODS.append((k, "symlinks"))
-_VENV_BUG_ON = (
- IS_PYPY
- and CURRENT.version_info[0:3] == (3, 6, 9)
- and CURRENT.pypy_version_info[0:2] == [7, 3, 0]
- and CURRENT.platform == "linux"
-)
@pytest.mark.parametrize(
("creator", "isolated"),
- [
- pytest.param(
- *i,
- marks=pytest.mark.xfail(
- reason="https://bitbucket.org/pypy/pypy/issues/3159/pypy36-730-venv-fails-with-copies-on-linux",
- strict=True,
- ),
- )
- if _VENV_BUG_ON and i[0][0] == "venv" and i[0][1] == "copies"
- else i
- for i in product(CREATE_METHODS, ["isolated", "global"])
- ],
- ids=lambda i: "-".join(i) if isinstance(i, tuple) else i,
+ [pytest.param(*i, id=f"{'-'.join(i[0])}-{i[1]}") for i in product(CREATE_METHODS, ["isolated", "global"])],
)
def test_create_no_seed(python, creator, isolated, system, coverage_env, special_name_dir):
dest = special_name_dir
@@ -226,10 +208,6 @@ def test_create_no_seed(python, creator, isolated, system, coverage_env, special
).strip()
assert result == "None"
- if isinstance(creator, CPython2PosixBase):
- make_file = debug["makefile_filename"]
- assert os.path.exists(make_file)
-
git_ignore = (dest / ".gitignore").read_text(encoding="utf-8")
assert git_ignore.splitlines() == ["# created by virtualenv automatically", "*"]
@@ -340,32 +318,6 @@ def test_home_path_is_exe_parent(tmp_path, creator):
assert any(os.path.exists(os.path.join(cfg["home"], exe)) for exe in exes)
-@pytest.mark.slow()
-@pytest.mark.usefixtures("current_fastest")
-def test_cross_major(cross_python, coverage_env, tmp_path, session_app_data):
- cmd = [
- "-p",
- cross_python.executable,
- str(tmp_path),
- "--no-setuptools",
- "--no-wheel",
- "--activators",
- "",
- ]
- result = cli_run(cmd)
- pip_scripts = {i.name.replace(".exe", "") for i in result.creator.script_dir.iterdir() if i.name.startswith("pip")}
- major, minor = cross_python.version_info[0:2]
- assert pip_scripts == {
- "pip",
- f"pip{major}",
- f"pip-{major}.{minor}",
- f"pip{major}.{minor}",
- }
- coverage_env()
- env = PythonInfo.from_exe(str(result.creator.exe), session_app_data)
- assert env.version_info.major != CURRENT.version_info.major
-
-
@pytest.mark.usefixtures("temp_app_data")
def test_create_parallel(tmp_path):
def create(count):
@@ -659,34 +611,3 @@ def test_python_path(monkeypatch, tmp_path, python_path_on):
assert non_python_path == [i for i in base if i not in extra_as_python_path]
else:
assert base == extra_all
-
-
-@pytest.mark.parametrize(
- ("py", "pyc"),
- product(
- [True, False] if Python2.from_stdlib(Python2.mappings(CURRENT), "os.py")[2] else [False],
- [True, False] if Python2.from_stdlib(Python2.mappings(CURRENT), "os.pyc")[2] else [False],
- ),
-)
-@pytest.mark.usefixtures("session_app_data")
-def test_py_pyc_missing(tmp_path, mocker, py, pyc):
- """Ensure that creation can succeed if os.pyc exists (even if os.py has been deleted)"""
- previous = Python2.from_stdlib
-
- def from_stdlib(mappings, name):
- path, to, exists = previous(mappings, name)
- if name.endswith("py"):
- exists = py
- elif name.endswith("pyc"):
- exists = pyc
- return path, to, exists
-
- mocker.patch.object(Python2, "from_stdlib", side_effect=from_stdlib)
-
- result = cli_run([str(tmp_path), "--without-pip", "--activators", "", "-vv", "-p", "2"])
- py_at = Python2.from_stdlib(Python2.mappings(CURRENT), "os.py")[1](result.creator, Path("os.py"))
- py = pyc is False or py # if pyc is False we fallback to serve the py, which will exist (as we only mock the check)
- assert py_at.exists() is py
-
- pyc_at = Python2.from_stdlib(Python2.mappings(CURRENT), "osc.py")[1](result.creator, Path("os.pyc"))
- assert pyc_at.exists() is pyc