559 lines
21 KiB
Diff
559 lines
21 KiB
Diff
From c966775dd5cce42353a32b4df67a03699aa8d445 Mon Sep 17 00:00:00 2001
|
|
From: Arun Babu Neelicattu <arun.neelicattu@gmail.com>
|
|
Date: Tue, 20 Oct 2020 18:32:36 +0200
|
|
Subject: [PATCH] tests: cleanup cache and http usage
|
|
|
|
- ensure tests rely on temporary cache directory
|
|
- remove external http call requirement for lock --no-update
|
|
|
|
Relates-to: #1645
|
|
(cherry picked from commit bf61dd56399b5d0cfadf66fed72b4d63062a827f)
|
|
|
|
# Conflicts:
|
|
# tests/console/commands/test_config.py
|
|
# tests/console/commands/test_lock.py
|
|
# tests/utils/test_env.py
|
|
---
|
|
tests/config/test_config.py | 4 +-
|
|
tests/conftest.py | 21 ++-
|
|
tests/console/commands/test_config.py | 30 ++--
|
|
tests/console/commands/test_lock.py | 37 +++--
|
|
tests/fixtures/old_lock/poetry.lock | 150 +-----------------
|
|
tests/fixtures/old_lock/pyproject.toml | 2 +-
|
|
tests/installation/test_chef.py | 7 +-
|
|
tests/installation/test_executor.py | 6 +-
|
|
.../masonry/builders/test_editable_builder.py | 8 +-
|
|
tests/utils/test_env.py | 26 ++-
|
|
10 files changed, 92 insertions(+), 199 deletions(-)
|
|
|
|
diff --git a/tests/config/test_config.py b/tests/config/test_config.py
|
|
index 4bd0cd04..f3b13f23 100644
|
|
--- a/tests/config/test_config.py
|
|
+++ b/tests/config/test_config.py
|
|
@@ -10,8 +10,8 @@ def test_config_get_default_value(config, name, value):
|
|
assert config.get(name) is value
|
|
|
|
|
|
-def test_config_get_processes_depended_on_values(config):
|
|
- assert os.path.join("/foo", "virtualenvs") == config.get("virtualenvs.path")
|
|
+def test_config_get_processes_depended_on_values(config, config_cache_dir):
|
|
+ assert str(config_cache_dir / "virtualenvs") == config.get("virtualenvs.path")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
diff --git a/tests/conftest.py b/tests/conftest.py
|
|
index e2b73936..51128f76 100644
|
|
--- a/tests/conftest.py
|
|
+++ b/tests/conftest.py
|
|
@@ -54,9 +54,21 @@ class Config(BaseConfig):
|
|
|
|
|
|
@pytest.fixture
|
|
-def config_source():
|
|
+def config_cache_dir(tmp_dir):
|
|
+ path = Path(tmp_dir) / ".cache" / "pypoetry"
|
|
+ path.mkdir(parents=True)
|
|
+ return path
|
|
+
|
|
+
|
|
+@pytest.fixture
|
|
+def config_virtualenvs_path(config_cache_dir):
|
|
+ return config_cache_dir / "virtualenvs"
|
|
+
|
|
+
|
|
+@pytest.fixture
|
|
+def config_source(config_cache_dir):
|
|
source = DictConfigSource()
|
|
- source.add_property("cache-dir", "/foo")
|
|
+ source.add_property("cache-dir", str(config_cache_dir))
|
|
|
|
return source
|
|
|
|
@@ -226,6 +238,7 @@ def project_factory(tmp_dir, config, repo, installed, default_python):
|
|
dependencies=None,
|
|
dev_dependencies=None,
|
|
pyproject_content=None,
|
|
+ poetry_lock_content=None,
|
|
install_deps=True,
|
|
):
|
|
project_dir = workspace / "poetry-fixture-{}".format(name)
|
|
@@ -249,6 +262,10 @@ def project_factory(tmp_dir, config, repo, installed, default_python):
|
|
dev_dependencies=dev_dependencies,
|
|
).create(project_dir, with_tests=False)
|
|
|
|
+ if poetry_lock_content:
|
|
+ lock_file = project_dir / "poetry.lock"
|
|
+ lock_file.write_text(data=poetry_lock_content, encoding="utf-8")
|
|
+
|
|
poetry = Factory().create_poetry(project_dir)
|
|
|
|
locker = TestLocker(
|
|
diff --git a/tests/console/commands/test_config.py b/tests/console/commands/test_config.py
|
|
index fa0bea4a..e85fb697 100644
|
|
--- a/tests/console/commands/test_config.py
|
|
+++ b/tests/console/commands/test_config.py
|
|
@@ -25,35 +25,39 @@ def test_show_config_with_local_config_file_empty(tester, mocker):
|
|
assert "" == tester.io.fetch_output()
|
|
|
|
|
|
-def test_list_displays_default_value_if_not_set(tester, config):
|
|
+def test_list_displays_default_value_if_not_set(tester, config, config_cache_dir):
|
|
tester.execute("--list")
|
|
|
|
- expected = """cache-dir = "/foo"
|
|
+ expected = """cache-dir = {cache}
|
|
experimental.new-installer = true
|
|
installer.parallel = true
|
|
virtualenvs.create = true
|
|
virtualenvs.in-project = null
|
|
-virtualenvs.path = {path} # /foo{sep}virtualenvs
|
|
+virtualenvs.path = {path} # {virtualenvs}
|
|
""".format(
|
|
- path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
|
|
+ cache=json.dumps(str(config_cache_dir)),
|
|
+ path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")),
|
|
+ virtualenvs=str(config_cache_dir / "virtualenvs"),
|
|
)
|
|
|
|
assert expected == tester.io.fetch_output()
|
|
|
|
|
|
-def test_list_displays_set_get_setting(tester, config):
|
|
+def test_list_displays_set_get_setting(tester, config, config_cache_dir):
|
|
tester.execute("virtualenvs.create false")
|
|
|
|
tester.execute("--list")
|
|
|
|
- expected = """cache-dir = "/foo"
|
|
+ expected = """cache-dir = {cache}
|
|
experimental.new-installer = true
|
|
installer.parallel = true
|
|
virtualenvs.create = false
|
|
virtualenvs.in-project = null
|
|
-virtualenvs.path = {path} # /foo{sep}virtualenvs
|
|
+virtualenvs.path = {path} # {virtualenvs}
|
|
""".format(
|
|
- path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
|
|
+ cache=json.dumps(str(config_cache_dir)),
|
|
+ path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")),
|
|
+ virtualenvs=str(config_cache_dir / "virtualenvs"),
|
|
)
|
|
|
|
assert 0 == config.set_config_source.call_count
|
|
@@ -81,19 +85,21 @@ def test_display_single_local_setting(command_tester_factory, fixture_dir):
|
|
assert expected == tester.io.fetch_output()
|
|
|
|
|
|
-def test_list_displays_set_get_local_setting(tester, config):
|
|
+def test_list_displays_set_get_local_setting(tester, config, config_cache_dir):
|
|
tester.execute("virtualenvs.create false --local")
|
|
|
|
tester.execute("--list")
|
|
|
|
- expected = """cache-dir = "/foo"
|
|
+ expected = """cache-dir = {cache}
|
|
experimental.new-installer = true
|
|
installer.parallel = true
|
|
virtualenvs.create = false
|
|
virtualenvs.in-project = null
|
|
-virtualenvs.path = {path} # /foo{sep}virtualenvs
|
|
+virtualenvs.path = {path} # {virtualenvs}
|
|
""".format(
|
|
- path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
|
|
+ cache=json.dumps(str(config_cache_dir)),
|
|
+ path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")),
|
|
+ virtualenvs=str(config_cache_dir / "virtualenvs"),
|
|
)
|
|
|
|
assert 1 == config.set_config_source.call_count
|
|
diff --git a/tests/console/commands/test_lock.py b/tests/console/commands/test_lock.py
|
|
index 823a8ba4..c05ba257 100644
|
|
--- a/tests/console/commands/test_lock.py
|
|
+++ b/tests/console/commands/test_lock.py
|
|
@@ -1,11 +1,8 @@
|
|
-import shutil
|
|
-import sys
|
|
-
|
|
import pytest
|
|
|
|
-from poetry.factory import Factory
|
|
from poetry.packages import Locker
|
|
from poetry.utils._compat import Path
|
|
+from tests.helpers import get_package
|
|
|
|
|
|
@pytest.fixture
|
|
@@ -19,18 +16,26 @@ def tester(command_tester_factory):
|
|
|
|
|
|
@pytest.fixture
|
|
-def poetry_with_old_lockfile(fixture_dir, source_dir):
|
|
- project_dir = source_dir / "project"
|
|
- shutil.copytree(str(fixture_dir("old_lock")), str(project_dir))
|
|
- poetry = Factory().create_poetry(cwd=project_dir)
|
|
- return poetry
|
|
-
|
|
-
|
|
-@pytest.mark.skipif(
|
|
- sys.platform == "win32", reason="does not work on windows under ci environments"
|
|
-)
|
|
-def test_lock_no_update(command_tester_factory, poetry_with_old_lockfile, http):
|
|
- http.disable()
|
|
+def poetry_with_old_lockfile(project_factory, fixture_dir, source_dir):
|
|
+ source = fixture_dir("old_lock")
|
|
+ pyproject_content = (source / "pyproject.toml").read_text(encoding="utf-8")
|
|
+ poetry_lock_content = (source / "poetry.lock").read_text(encoding="utf-8")
|
|
+ return project_factory(
|
|
+ name="foobar",
|
|
+ pyproject_content=pyproject_content,
|
|
+ poetry_lock_content=poetry_lock_content,
|
|
+ )
|
|
+
|
|
+
|
|
+def test_lock_no_update(command_tester_factory, poetry_with_old_lockfile, repo):
|
|
+ repo.add_package(get_package("sampleproject", "1.3.1"))
|
|
+ repo.add_package(get_package("sampleproject", "2.0.0"))
|
|
+
|
|
+ locker = Locker(
|
|
+ lock=poetry_with_old_lockfile.pyproject.file.path.parent / "poetry.lock",
|
|
+ local_config=poetry_with_old_lockfile.locker._local_config,
|
|
+ )
|
|
+ poetry_with_old_lockfile.set_locker(locker)
|
|
|
|
locked_repository = poetry_with_old_lockfile.locker.locked_repository(
|
|
with_dev_reqs=True
|
|
diff --git a/tests/fixtures/old_lock/poetry.lock b/tests/fixtures/old_lock/poetry.lock
|
|
index 57d58570..498df2ed 100644
|
|
--- a/tests/fixtures/old_lock/poetry.lock
|
|
+++ b/tests/fixtures/old_lock/poetry.lock
|
|
@@ -1,153 +1,19 @@
|
|
[[package]]
|
|
category = "main"
|
|
-description = "Python package for providing Mozilla's CA Bundle."
|
|
-name = "certifi"
|
|
-optional = false
|
|
-python-versions = "*"
|
|
-version = "2020.6.20"
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "Universal encoding detector for Python 2 and 3"
|
|
-name = "chardet"
|
|
-optional = false
|
|
-python-versions = "*"
|
|
-version = "3.0.4"
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "A Python library for the Docker Engine API."
|
|
-name = "docker"
|
|
-optional = false
|
|
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
|
-version = "4.3.1"
|
|
-
|
|
-[package.dependencies]
|
|
-pywin32 = "227"
|
|
-requests = ">=2.14.2,<2.18.0 || >2.18.0"
|
|
-six = ">=1.4.0"
|
|
-websocket-client = ">=0.32.0"
|
|
-
|
|
-[package.extras]
|
|
-ssh = ["paramiko (>=2.4.2)"]
|
|
-tls = ["pyOpenSSL (>=17.5.0)", "cryptography (>=1.3.4)", "idna (>=2.0.0)"]
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "Internationalized Domain Names in Applications (IDNA)"
|
|
-name = "idna"
|
|
-optional = false
|
|
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
|
-version = "2.10"
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "Python for Window Extensions"
|
|
-marker = "sys_platform == \"win32\""
|
|
-name = "pywin32"
|
|
-optional = false
|
|
-python-versions = "*"
|
|
-version = "227"
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "Python HTTP for Humans."
|
|
-name = "requests"
|
|
-optional = false
|
|
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
|
-version = "2.24.0"
|
|
-
|
|
-[package.dependencies]
|
|
-certifi = ">=2017.4.17"
|
|
-chardet = ">=3.0.2,<4"
|
|
-idna = ">=2.5,<3"
|
|
-urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26"
|
|
-
|
|
-[package.extras]
|
|
-security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"]
|
|
-socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"]
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "Python 2 and 3 compatibility utilities"
|
|
-name = "six"
|
|
-optional = false
|
|
-python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
|
|
-version = "1.15.0"
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "HTTP library with thread-safe connection pooling, file post, and more."
|
|
-name = "urllib3"
|
|
+description = "A sample Python project"
|
|
+name = "sampleproject"
|
|
optional = false
|
|
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
|
|
-version = "1.25.10"
|
|
-
|
|
-[package.extras]
|
|
-brotli = ["brotlipy (>=0.6.0)"]
|
|
-secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0.14)", "ipaddress"]
|
|
-socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"]
|
|
-
|
|
-[[package]]
|
|
-category = "main"
|
|
-description = "WebSocket client for Python. hybi13 is supported."
|
|
-name = "websocket-client"
|
|
-optional = false
|
|
-python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
|
-version = "0.57.0"
|
|
-
|
|
-[package.dependencies]
|
|
-six = "*"
|
|
+version = "1.3.1"
|
|
|
|
[metadata]
|
|
-content-hash = "bb4c2f3c089b802c1930b6acbeed04711d93e9cdfd9a003eb17518a6d9f350c6"
|
|
+content-hash = "c8c2c9d899e47bac3972e029ef0e71b75d5df98a28eebef25a75640a19aac177"
|
|
lock-version = "1.0"
|
|
python-versions = "^3.8"
|
|
|
|
[metadata.files]
|
|
-certifi = [
|
|
- {file = "certifi-2020.6.20-py2.py3-none-any.whl", hash = "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"},
|
|
- {file = "certifi-2020.6.20.tar.gz", hash = "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3"},
|
|
-]
|
|
-chardet = [
|
|
- {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"},
|
|
- {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"},
|
|
-]
|
|
-docker = [
|
|
- {file = "docker-4.3.1-py2.py3-none-any.whl", hash = "sha256:13966471e8bc23b36bfb3a6fb4ab75043a5ef1dac86516274777576bed3b9828"},
|
|
- {file = "docker-4.3.1.tar.gz", hash = "sha256:bad94b8dd001a8a4af19ce4becc17f41b09f228173ffe6a4e0355389eef142f2"},
|
|
-]
|
|
-idna = [
|
|
- {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"},
|
|
- {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"},
|
|
-]
|
|
-pywin32 = [
|
|
- {file = "pywin32-227-cp27-cp27m-win32.whl", hash = "sha256:371fcc39416d736401f0274dd64c2302728c9e034808e37381b5e1b22be4a6b0"},
|
|
- {file = "pywin32-227-cp27-cp27m-win_amd64.whl", hash = "sha256:4cdad3e84191194ea6d0dd1b1b9bdda574ff563177d2adf2b4efec2a244fa116"},
|
|
- {file = "pywin32-227-cp35-cp35m-win32.whl", hash = "sha256:f4c5be1a293bae0076d93c88f37ee8da68136744588bc5e2be2f299a34ceb7aa"},
|
|
- {file = "pywin32-227-cp35-cp35m-win_amd64.whl", hash = "sha256:a929a4af626e530383a579431b70e512e736e9588106715215bf685a3ea508d4"},
|
|
- {file = "pywin32-227-cp36-cp36m-win32.whl", hash = "sha256:300a2db938e98c3e7e2093e4491439e62287d0d493fe07cce110db070b54c0be"},
|
|
- {file = "pywin32-227-cp36-cp36m-win_amd64.whl", hash = "sha256:9b31e009564fb95db160f154e2aa195ed66bcc4c058ed72850d047141b36f3a2"},
|
|
- {file = "pywin32-227-cp37-cp37m-win32.whl", hash = "sha256:47a3c7551376a865dd8d095a98deba954a98f326c6fe3c72d8726ca6e6b15507"},
|
|
- {file = "pywin32-227-cp37-cp37m-win_amd64.whl", hash = "sha256:31f88a89139cb2adc40f8f0e65ee56a8c585f629974f9e07622ba80199057511"},
|
|
- {file = "pywin32-227-cp38-cp38-win32.whl", hash = "sha256:7f18199fbf29ca99dff10e1f09451582ae9e372a892ff03a28528a24d55875bc"},
|
|
- {file = "pywin32-227-cp38-cp38-win_amd64.whl", hash = "sha256:7c1ae32c489dc012930787f06244426f8356e129184a02c25aef163917ce158e"},
|
|
- {file = "pywin32-227-cp39-cp39-win32.whl", hash = "sha256:c054c52ba46e7eb6b7d7dfae4dbd987a1bb48ee86debe3f245a2884ece46e295"},
|
|
- {file = "pywin32-227-cp39-cp39-win_amd64.whl", hash = "sha256:f27cec5e7f588c3d1051651830ecc00294f90728d19c3bf6916e6dba93ea357c"},
|
|
-]
|
|
-requests = [
|
|
- {file = "requests-2.24.0-py2.py3-none-any.whl", hash = "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"},
|
|
- {file = "requests-2.24.0.tar.gz", hash = "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b"},
|
|
-]
|
|
-six = [
|
|
- {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
|
|
- {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
|
|
-]
|
|
-urllib3 = [
|
|
- {file = "urllib3-1.25.10-py2.py3-none-any.whl", hash = "sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461"},
|
|
- {file = "urllib3-1.25.10.tar.gz", hash = "sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a"},
|
|
-]
|
|
-websocket-client = [
|
|
- {file = "websocket_client-0.57.0-py2.py3-none-any.whl", hash = "sha256:0fc45c961324d79c781bab301359d5a1b00b13ad1b10415a4780229ef71a5549"},
|
|
- {file = "websocket_client-0.57.0.tar.gz", hash = "sha256:d735b91d6d1692a6a181f2a8c9e0238e5f6373356f561bb9dc4c7af36f452010"},
|
|
+sampleproject = [
|
|
+ {file = "sampleproject-1.3.1-py2.py3-none-any.whl", hash = "sha256:26c9172e08244873b0e09c574a229bf2c251c67723a05e08fd3ec0c5ee423796"},
|
|
+ {file = "sampleproject-1.3.1-py3-none-any.whl", hash = "sha256:75bb5bb4e74a1b77dc0cff25ebbacb54fe1318aaf99a86a036cefc86ed885ced"},
|
|
+ {file = "sampleproject-1.3.1.tar.gz", hash = "sha256:3593ca2f1e057279d70d6144b14472fb28035b1da213dde60906b703d6f82c55"},
|
|
]
|
|
diff --git a/tests/fixtures/old_lock/pyproject.toml b/tests/fixtures/old_lock/pyproject.toml
|
|
index 56ea6350..377aa676 100644
|
|
--- a/tests/fixtures/old_lock/pyproject.toml
|
|
+++ b/tests/fixtures/old_lock/pyproject.toml
|
|
@@ -6,7 +6,7 @@ authors = ["Poetry Developer <developer@python-poetry.org>"]
|
|
|
|
[tool.poetry.dependencies]
|
|
python = "^3.8"
|
|
-docker = "^4.3.1"
|
|
+sampleproject = ">=1.3.1"
|
|
|
|
[tool.poetry.dev-dependencies]
|
|
|
|
diff --git a/tests/installation/test_chef.py b/tests/installation/test_chef.py
|
|
index 9fcbbea1..4e59b608 100644
|
|
--- a/tests/installation/test_chef.py
|
|
+++ b/tests/installation/test_chef.py
|
|
@@ -60,7 +60,7 @@ def test_get_cached_archives_for_link(config, mocker):
|
|
}
|
|
|
|
|
|
-def test_get_cache_directory_for_link(config):
|
|
+def test_get_cache_directory_for_link(config, config_cache_dir):
|
|
chef = Chef(
|
|
config,
|
|
MockEnv(
|
|
@@ -71,8 +71,11 @@ def test_get_cache_directory_for_link(config):
|
|
directory = chef.get_cache_directory_for_link(
|
|
Link("https://files.python-poetry.org/poetry-1.1.0.tar.gz")
|
|
)
|
|
+
|
|
expected = Path(
|
|
- "/foo/artifacts/ba/63/13/283a3b3b7f95f05e9e6f84182d276f7bb0951d5b0cc24422b33f7a4648"
|
|
+ "{}/artifacts/ba/63/13/283a3b3b7f95f05e9e6f84182d276f7bb0951d5b0cc24422b33f7a4648".format(
|
|
+ config_cache_dir.as_posix()
|
|
+ )
|
|
)
|
|
|
|
assert expected == directory
|
|
diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py
|
|
index bb659321..3dfd818b 100644
|
|
--- a/tests/installation/test_executor.py
|
|
+++ b/tests/installation/test_executor.py
|
|
@@ -126,9 +126,11 @@ Package operations: 4 installs, 1 update, 1 removal
|
|
assert 5 == len(env.executed)
|
|
|
|
|
|
-def test_execute_shows_skipped_operations_if_verbose(config, pool, io):
|
|
+def test_execute_shows_skipped_operations_if_verbose(
|
|
+ config, pool, io, config_cache_dir
|
|
+):
|
|
config = Config()
|
|
- config.merge({"cache-dir": "/foo"})
|
|
+ config.merge({"cache-dir": config_cache_dir.as_posix()})
|
|
|
|
env = MockEnv()
|
|
executor = Executor(env, pool, config, io)
|
|
diff --git a/tests/masonry/builders/test_editable_builder.py b/tests/masonry/builders/test_editable_builder.py
|
|
index daeff0e7..3bf1e59c 100644
|
|
--- a/tests/masonry/builders/test_editable_builder.py
|
|
+++ b/tests/masonry/builders/test_editable_builder.py
|
|
@@ -176,9 +176,9 @@ if __name__ == '__main__':
|
|
|
|
|
|
def test_builder_falls_back_on_setup_and_pip_for_packages_with_build_scripts(
|
|
- extended_poetry,
|
|
+ extended_poetry, tmp_dir
|
|
):
|
|
- env = MockEnv(path=Path("/foo"))
|
|
+ env = MockEnv(path=Path(tmp_dir) / "foo")
|
|
builder = EditableBuilder(extended_poetry, env, NullIO())
|
|
|
|
builder.build()
|
|
@@ -219,8 +219,8 @@ def test_builder_installs_proper_files_when_packages_configured(
|
|
assert len(paths) == len(expected)
|
|
|
|
|
|
-def test_builder_should_execute_build_scripts(extended_without_setup_poetry):
|
|
- env = MockEnv(path=Path("/foo"))
|
|
+def test_builder_should_execute_build_scripts(extended_without_setup_poetry, tmp_dir):
|
|
+ env = MockEnv(path=Path(tmp_dir) / "foo")
|
|
builder = EditableBuilder(extended_without_setup_poetry, env, NullIO())
|
|
|
|
builder.build()
|
|
diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py
|
|
index cd5e1b9f..ad1e17f2 100644
|
|
--- a/tests/utils/test_env.py
|
|
+++ b/tests/utils/test_env.py
|
|
@@ -634,7 +634,7 @@ def test_run_with_input_non_zero_return(tmp_dir, tmp_venv):
|
|
|
|
|
|
def test_create_venv_tries_to_find_a_compatible_python_executable_using_generic_ones_first(
|
|
- manager, poetry, config, mocker
|
|
+ manager, poetry, config, mocker, config_virtualenvs_path
|
|
):
|
|
if "VIRTUAL_ENV" in os.environ:
|
|
del os.environ["VIRTUAL_ENV"]
|
|
@@ -654,12 +654,12 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_generic_
|
|
manager.create_venv(NullIO())
|
|
|
|
m.assert_called_with(
|
|
- Path("/foo/virtualenvs/{}-py3.7".format(venv_name)), executable="python3"
|
|
+ config_virtualenvs_path / "{}-py3.7".format(venv_name), executable="python3"
|
|
)
|
|
|
|
|
|
def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific_ones(
|
|
- manager, poetry, config, mocker
|
|
+ manager, poetry, config, mocker, config_virtualenvs_path
|
|
):
|
|
if "VIRTUAL_ENV" in os.environ:
|
|
del os.environ["VIRTUAL_ENV"]
|
|
@@ -678,7 +678,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
|
|
manager.create_venv(NullIO())
|
|
|
|
m.assert_called_with(
|
|
- Path("/foo/virtualenvs/{}-py3.9".format(venv_name)), executable="python3.9"
|
|
+ config_virtualenvs_path / "{}-py3.9".format(venv_name), executable="python3.9"
|
|
)
|
|
|
|
|
|
@@ -737,7 +737,7 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
|
|
|
|
|
|
def test_create_venv_uses_patch_version_to_detect_compatibility(
|
|
- manager, poetry, config, mocker
|
|
+ manager, poetry, config, mocker, config_virtualenvs_path
|
|
):
|
|
if "VIRTUAL_ENV" in os.environ:
|
|
del os.environ["VIRTUAL_ENV"]
|
|
@@ -761,17 +761,14 @@ def test_create_venv_uses_patch_version_to_detect_compatibility(
|
|
|
|
assert not check_output.called
|
|
m.assert_called_with(
|
|
- Path(
|
|
- "/foo/virtualenvs/{}-py{}.{}".format(
|
|
- venv_name, version.major, version.minor
|
|
- )
|
|
- ),
|
|
+ config_virtualenvs_path
|
|
+ / "{}-py{}.{}".format(venv_name, version.major, version.minor),
|
|
executable=None,
|
|
)
|
|
|
|
|
|
def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable(
|
|
- manager, poetry, config, mocker
|
|
+ manager, poetry, config, mocker, config_virtualenvs_path
|
|
):
|
|
if "VIRTUAL_ENV" in os.environ:
|
|
del os.environ["VIRTUAL_ENV"]
|
|
@@ -798,11 +795,8 @@ def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable(
|
|
|
|
assert check_output.called
|
|
m.assert_called_with(
|
|
- Path(
|
|
- "/foo/virtualenvs/{}-py{}.{}".format(
|
|
- venv_name, version.major, version.minor - 1
|
|
- )
|
|
- ),
|
|
+ config_virtualenvs_path
|
|
+ / "{}-py{}.{}".format(venv_name, version.major, version.minor - 1),
|
|
executable="python{}.{}".format(version.major, version.minor - 1),
|
|
)
|
|
|
|
--
|
|
2.30.0
|
|
|