summaryrefslogtreecommitdiff
path: root/python3-poetry/0001-tests-cleanup-cache-and-http-usage.patch
blob: 178b8020b994d6d35d883c03509a89eca4c384f5 (plain)
    1 From c966775dd5cce42353a32b4df67a03699aa8d445 Mon Sep 17 00:00:00 2001
    2 From: Arun Babu Neelicattu <arun.neelicattu@gmail.com>
    3 Date: Tue, 20 Oct 2020 18:32:36 +0200
    4 Subject: [PATCH] tests: cleanup cache and http usage
    5 
    6 - ensure tests rely on temporary cache directory
    7 - remove external http call requirement for lock --no-update
    8 
    9 Relates-to: #1645
   10 (cherry picked from commit bf61dd56399b5d0cfadf66fed72b4d63062a827f)
   11 
   12 # Conflicts:
   13 #	tests/console/commands/test_config.py
   14 #	tests/console/commands/test_lock.py
   15 #	tests/utils/test_env.py
   16 ---
   17  tests/config/test_config.py                   |   4 +-
   18  tests/conftest.py                             |  21 ++-
   19  tests/console/commands/test_config.py         |  30 ++--
   20  tests/console/commands/test_lock.py           |  37 +++--
   21  tests/fixtures/old_lock/poetry.lock           | 150 +-----------------
   22  tests/fixtures/old_lock/pyproject.toml        |   2 +-
   23  tests/installation/test_chef.py               |   7 +-
   24  tests/installation/test_executor.py           |   6 +-
   25  .../masonry/builders/test_editable_builder.py |   8 +-
   26  tests/utils/test_env.py                       |  26 ++-
   27  10 files changed, 92 insertions(+), 199 deletions(-)
   28 
   29 diff --git a/tests/config/test_config.py b/tests/config/test_config.py
   30 index 4bd0cd04..f3b13f23 100644
   31 --- a/tests/config/test_config.py
   32 +++ b/tests/config/test_config.py
   33 @@ -10,8 +10,8 @@ def test_config_get_default_value(config, name, value):
   34      assert config.get(name) is value
   35  
   36  
   37 -def test_config_get_processes_depended_on_values(config):
   38 -    assert os.path.join("/foo", "virtualenvs") == config.get("virtualenvs.path")
   39 +def test_config_get_processes_depended_on_values(config, config_cache_dir):
   40 +    assert str(config_cache_dir / "virtualenvs") == config.get("virtualenvs.path")
   41  
   42  
   43  @pytest.mark.parametrize(
   44 diff --git a/tests/conftest.py b/tests/conftest.py
   45 index e2b73936..51128f76 100644
   46 --- a/tests/conftest.py
   47 +++ b/tests/conftest.py
   48 @@ -54,9 +54,21 @@ class Config(BaseConfig):
   49  
   50  
   51  @pytest.fixture
   52 -def config_source():
   53 +def config_cache_dir(tmp_dir):
   54 +    path = Path(tmp_dir) / ".cache" / "pypoetry"
   55 +    path.mkdir(parents=True)
   56 +    return path
   57 +
   58 +
   59 +@pytest.fixture
   60 +def config_virtualenvs_path(config_cache_dir):
   61 +    return config_cache_dir / "virtualenvs"
   62 +
   63 +
   64 +@pytest.fixture
   65 +def config_source(config_cache_dir):
   66      source = DictConfigSource()
   67 -    source.add_property("cache-dir", "/foo")
   68 +    source.add_property("cache-dir", str(config_cache_dir))
   69  
   70      return source
   71  
   72 @@ -226,6 +238,7 @@ def project_factory(tmp_dir, config, repo, installed, default_python):
   73          dependencies=None,
   74          dev_dependencies=None,
   75          pyproject_content=None,
   76 +        poetry_lock_content=None,
   77          install_deps=True,
   78      ):
   79          project_dir = workspace / "poetry-fixture-{}".format(name)
   80 @@ -249,6 +262,10 @@ def project_factory(tmp_dir, config, repo, installed, default_python):
   81                  dev_dependencies=dev_dependencies,
   82              ).create(project_dir, with_tests=False)
   83  
   84 +        if poetry_lock_content:
   85 +            lock_file = project_dir / "poetry.lock"
   86 +            lock_file.write_text(data=poetry_lock_content, encoding="utf-8")
   87 +
   88          poetry = Factory().create_poetry(project_dir)
   89  
   90          locker = TestLocker(
   91 diff --git a/tests/console/commands/test_config.py b/tests/console/commands/test_config.py
   92 index fa0bea4a..e85fb697 100644
   93 --- a/tests/console/commands/test_config.py
   94 +++ b/tests/console/commands/test_config.py
   95 @@ -25,35 +25,39 @@ def test_show_config_with_local_config_file_empty(tester, mocker):
   96      assert "" == tester.io.fetch_output()
   97  
   98  
   99 -def test_list_displays_default_value_if_not_set(tester, config):
  100 +def test_list_displays_default_value_if_not_set(tester, config, config_cache_dir):
  101      tester.execute("--list")
  102  
  103 -    expected = """cache-dir = "/foo"
  104 +    expected = """cache-dir = {cache}
  105  experimental.new-installer = true
  106  installer.parallel = true
  107  virtualenvs.create = true
  108  virtualenvs.in-project = null
  109 -virtualenvs.path = {path}  # /foo{sep}virtualenvs
  110 +virtualenvs.path = {path}  # {virtualenvs}
  111  """.format(
  112 -        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
  113 +        cache=json.dumps(str(config_cache_dir)),
  114 +        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")),
  115 +        virtualenvs=str(config_cache_dir / "virtualenvs"),
  116      )
  117  
  118      assert expected == tester.io.fetch_output()
  119  
  120  
  121 -def test_list_displays_set_get_setting(tester, config):
  122 +def test_list_displays_set_get_setting(tester, config, config_cache_dir):
  123      tester.execute("virtualenvs.create false")
  124  
  125      tester.execute("--list")
  126  
  127 -    expected = """cache-dir = "/foo"
  128 +    expected = """cache-dir = {cache}
  129  experimental.new-installer = true
  130  installer.parallel = true
  131  virtualenvs.create = false
  132  virtualenvs.in-project = null
  133 -virtualenvs.path = {path}  # /foo{sep}virtualenvs
  134 +virtualenvs.path = {path}  # {virtualenvs}
  135  """.format(
  136 -        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
  137 +        cache=json.dumps(str(config_cache_dir)),
  138 +        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")),
  139 +        virtualenvs=str(config_cache_dir / "virtualenvs"),
  140      )
  141  
  142      assert 0 == config.set_config_source.call_count
  143 @@ -81,19 +85,21 @@ def test_display_single_local_setting(command_tester_factory, fixture_dir):
  144      assert expected == tester.io.fetch_output()
  145  
  146  
  147 -def test_list_displays_set_get_local_setting(tester, config):
  148 +def test_list_displays_set_get_local_setting(tester, config, config_cache_dir):
  149      tester.execute("virtualenvs.create false --local")
  150  
  151      tester.execute("--list")
  152  
  153 -    expected = """cache-dir = "/foo"
  154 +    expected = """cache-dir = {cache}
  155  experimental.new-installer = true
  156  installer.parallel = true
  157  virtualenvs.create = false
  158  virtualenvs.in-project = null
  159 -virtualenvs.path = {path}  # /foo{sep}virtualenvs
  160 +virtualenvs.path = {path}  # {virtualenvs}
  161  """.format(
  162 -        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
  163 +        cache=json.dumps(str(config_cache_dir)),
  164 +        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")),
  165 +        virtualenvs=str(config_cache_dir / "virtualenvs"),
  166      )
  167  
  168      assert 1 == config.set_config_source.call_count
  169 diff --git a/tests/console/commands/test_lock.py b/tests/console/commands/test_lock.py
  170 index 823a8ba4..c05ba257 100644
  171 --- a/tests/console/commands/test_lock.py
  172 +++ b/tests/console/commands/test_lock.py
  173 @@ -1,11 +1,8 @@
  174 -import shutil
  175 -import sys
  176 -
  177  import pytest
  178  
  179 -from poetry.factory import Factory
  180  from poetry.packages import Locker
  181  from poetry.utils._compat import Path
  182 +from tests.helpers import get_package
  183  
  184  
  185  @pytest.fixture
  186 @@ -19,18 +16,26 @@ def tester(command_tester_factory):
  187  
  188  
  189  @pytest.fixture
  190 -def poetry_with_old_lockfile(fixture_dir, source_dir):
  191 -    project_dir = source_dir / "project"
  192 -    shutil.copytree(str(fixture_dir("old_lock")), str(project_dir))
  193 -    poetry = Factory().create_poetry(cwd=project_dir)
  194 -    return poetry
  195 -
  196 -
  197 -@pytest.mark.skipif(
  198 -    sys.platform == "win32", reason="does not work on windows under ci environments"
  199 -)
  200 -def test_lock_no_update(command_tester_factory, poetry_with_old_lockfile, http):
  201 -    http.disable()
  202 +def poetry_with_old_lockfile(project_factory, fixture_dir, source_dir):
  203 +    source = fixture_dir("old_lock")
  204 +    pyproject_content = (source / "pyproject.toml").read_text(encoding="utf-8")
  205 +    poetry_lock_content = (source / "poetry.lock").read_text(encoding="utf-8")
  206 +    return project_factory(
  207 +        name="foobar",
  208 +        pyproject_content=pyproject_content,
  209 +        poetry_lock_content=poetry_lock_content,
  210 +    )
  211 +
  212 +
  213 +def test_lock_no_update(command_tester_factory, poetry_with_old_lockfile, repo):
  214 +    repo.add_package(get_package("sampleproject", "1.3.1"))
  215 +    repo.add_package(get_package("sampleproject", "2.0.0"))
  216 +
  217 +    locker = Locker(
  218 +        lock=poetry_with_old_lockfile.pyproject.file.path.parent / "poetry.lock",
  219 +        local_config=poetry_with_old_lockfile.locker._local_config,
  220 +    )
  221 +    poetry_with_old_lockfile.set_locker(locker)
  222  
  223      locked_repository = poetry_with_old_lockfile.locker.locked_repository(
  224          with_dev_reqs=True
  225 diff --git a/tests/fixtures/old_lock/poetry.lock b/tests/fixtures/old_lock/poetry.lock
  226 index 57d58570..498df2ed 100644
  227 --- a/tests/fixtures/old_lock/poetry.lock
  228 +++ b/tests/fixtures/old_lock/poetry.lock
  229 @@ -1,153 +1,19 @@
  230  [[package]]
  231  category = "main"
  232 -description = "Python package for providing Mozilla's CA Bundle."
  233 -name = "certifi"
  234 -optional = false
  235 -python-versions = "*"
  236 -version = "2020.6.20"
  237 -
  238 -[[package]]
  239 -category = "main"
  240 -description = "Universal encoding detector for Python 2 and 3"
  241 -name = "chardet"
  242 -optional = false
  243 -python-versions = "*"
  244 -version = "3.0.4"
  245 -
  246 -[[package]]
  247 -category = "main"
  248 -description = "A Python library for the Docker Engine API."
  249 -name = "docker"
  250 -optional = false
  251 -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
  252 -version = "4.3.1"
  253 -
  254 -[package.dependencies]
  255 -pywin32 = "227"
  256 -requests = ">=2.14.2,<2.18.0 || >2.18.0"
  257 -six = ">=1.4.0"
  258 -websocket-client = ">=0.32.0"
  259 -
  260 -[package.extras]
  261 -ssh = ["paramiko (>=2.4.2)"]
  262 -tls = ["pyOpenSSL (>=17.5.0)", "cryptography (>=1.3.4)", "idna (>=2.0.0)"]
  263 -
  264 -[[package]]
  265 -category = "main"
  266 -description = "Internationalized Domain Names in Applications (IDNA)"
  267 -name = "idna"
  268 -optional = false
  269 -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
  270 -version = "2.10"
  271 -
  272 -[[package]]
  273 -category = "main"
  274 -description = "Python for Window Extensions"
  275 -marker = "sys_platform == \"win32\""
  276 -name = "pywin32"
  277 -optional = false
  278 -python-versions = "*"
  279 -version = "227"
  280 -
  281 -[[package]]
  282 -category = "main"
  283 -description = "Python HTTP for Humans."
  284 -name = "requests"
  285 -optional = false
  286 -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
  287 -version = "2.24.0"
  288 -
  289 -[package.dependencies]
  290 -certifi = ">=2017.4.17"
  291 -chardet = ">=3.0.2,<4"
  292 -idna = ">=2.5,<3"
  293 -urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26"
  294 -
  295 -[package.extras]
  296 -security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"]
  297 -socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"]
  298 -
  299 -[[package]]
  300 -category = "main"
  301 -description = "Python 2 and 3 compatibility utilities"
  302 -name = "six"
  303 -optional = false
  304 -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
  305 -version = "1.15.0"
  306 -
  307 -[[package]]
  308 -category = "main"
  309 -description = "HTTP library with thread-safe connection pooling, file post, and more."
  310 -name = "urllib3"
  311 +description = "A sample Python project"
  312 +name = "sampleproject"
  313  optional = false
  314  python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
  315 -version = "1.25.10"
  316 -
  317 -[package.extras]
  318 -brotli = ["brotlipy (>=0.6.0)"]
  319 -secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "pyOpenSSL (>=0.14)", "ipaddress"]
  320 -socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"]
  321 -
  322 -[[package]]
  323 -category = "main"
  324 -description = "WebSocket client for Python. hybi13 is supported."
  325 -name = "websocket-client"
  326 -optional = false
  327 -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
  328 -version = "0.57.0"
  329 -
  330 -[package.dependencies]
  331 -six = "*"
  332 +version = "1.3.1"
  333  
  334  [metadata]
  335 -content-hash = "bb4c2f3c089b802c1930b6acbeed04711d93e9cdfd9a003eb17518a6d9f350c6"
  336 +content-hash = "c8c2c9d899e47bac3972e029ef0e71b75d5df98a28eebef25a75640a19aac177"
  337  lock-version = "1.0"
  338  python-versions = "^3.8"
  339  
  340  [metadata.files]
  341 -certifi = [
  342 -    {file = "certifi-2020.6.20-py2.py3-none-any.whl", hash = "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"},
  343 -    {file = "certifi-2020.6.20.tar.gz", hash = "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3"},
  344 -]
  345 -chardet = [
  346 -    {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"},
  347 -    {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"},
  348 -]
  349 -docker = [
  350 -    {file = "docker-4.3.1-py2.py3-none-any.whl", hash = "sha256:13966471e8bc23b36bfb3a6fb4ab75043a5ef1dac86516274777576bed3b9828"},
  351 -    {file = "docker-4.3.1.tar.gz", hash = "sha256:bad94b8dd001a8a4af19ce4becc17f41b09f228173ffe6a4e0355389eef142f2"},
  352 -]
  353 -idna = [
  354 -    {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"},
  355 -    {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"},
  356 -]
  357 -pywin32 = [
  358 -    {file = "pywin32-227-cp27-cp27m-win32.whl", hash = "sha256:371fcc39416d736401f0274dd64c2302728c9e034808e37381b5e1b22be4a6b0"},
  359 -    {file = "pywin32-227-cp27-cp27m-win_amd64.whl", hash = "sha256:4cdad3e84191194ea6d0dd1b1b9bdda574ff563177d2adf2b4efec2a244fa116"},
  360 -    {file = "pywin32-227-cp35-cp35m-win32.whl", hash = "sha256:f4c5be1a293bae0076d93c88f37ee8da68136744588bc5e2be2f299a34ceb7aa"},
  361 -    {file = "pywin32-227-cp35-cp35m-win_amd64.whl", hash = "sha256:a929a4af626e530383a579431b70e512e736e9588106715215bf685a3ea508d4"},
  362 -    {file = "pywin32-227-cp36-cp36m-win32.whl", hash = "sha256:300a2db938e98c3e7e2093e4491439e62287d0d493fe07cce110db070b54c0be"},
  363 -    {file = "pywin32-227-cp36-cp36m-win_amd64.whl", hash = "sha256:9b31e009564fb95db160f154e2aa195ed66bcc4c058ed72850d047141b36f3a2"},
  364 -    {file = "pywin32-227-cp37-cp37m-win32.whl", hash = "sha256:47a3c7551376a865dd8d095a98deba954a98f326c6fe3c72d8726ca6e6b15507"},
  365 -    {file = "pywin32-227-cp37-cp37m-win_amd64.whl", hash = "sha256:31f88a89139cb2adc40f8f0e65ee56a8c585f629974f9e07622ba80199057511"},
  366 -    {file = "pywin32-227-cp38-cp38-win32.whl", hash = "sha256:7f18199fbf29ca99dff10e1f09451582ae9e372a892ff03a28528a24d55875bc"},
  367 -    {file = "pywin32-227-cp38-cp38-win_amd64.whl", hash = "sha256:7c1ae32c489dc012930787f06244426f8356e129184a02c25aef163917ce158e"},
  368 -    {file = "pywin32-227-cp39-cp39-win32.whl", hash = "sha256:c054c52ba46e7eb6b7d7dfae4dbd987a1bb48ee86debe3f245a2884ece46e295"},
  369 -    {file = "pywin32-227-cp39-cp39-win_amd64.whl", hash = "sha256:f27cec5e7f588c3d1051651830ecc00294f90728d19c3bf6916e6dba93ea357c"},
  370 -]
  371 -requests = [
  372 -    {file = "requests-2.24.0-py2.py3-none-any.whl", hash = "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"},
  373 -    {file = "requests-2.24.0.tar.gz", hash = "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b"},
  374 -]
  375 -six = [
  376 -    {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
  377 -    {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
  378 -]
  379 -urllib3 = [
  380 -    {file = "urllib3-1.25.10-py2.py3-none-any.whl", hash = "sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461"},
  381 -    {file = "urllib3-1.25.10.tar.gz", hash = "sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a"},
  382 -]
  383 -websocket-client = [
  384 -    {file = "websocket_client-0.57.0-py2.py3-none-any.whl", hash = "sha256:0fc45c961324d79c781bab301359d5a1b00b13ad1b10415a4780229ef71a5549"},
  385 -    {file = "websocket_client-0.57.0.tar.gz", hash = "sha256:d735b91d6d1692a6a181f2a8c9e0238e5f6373356f561bb9dc4c7af36f452010"},
  386 +sampleproject = [
  387 +    {file = "sampleproject-1.3.1-py2.py3-none-any.whl", hash = "sha256:26c9172e08244873b0e09c574a229bf2c251c67723a05e08fd3ec0c5ee423796"},
  388 +    {file = "sampleproject-1.3.1-py3-none-any.whl", hash = "sha256:75bb5bb4e74a1b77dc0cff25ebbacb54fe1318aaf99a86a036cefc86ed885ced"},
  389 +    {file = "sampleproject-1.3.1.tar.gz", hash = "sha256:3593ca2f1e057279d70d6144b14472fb28035b1da213dde60906b703d6f82c55"},
  390  ]
  391 diff --git a/tests/fixtures/old_lock/pyproject.toml b/tests/fixtures/old_lock/pyproject.toml
  392 index 56ea6350..377aa676 100644
  393 --- a/tests/fixtures/old_lock/pyproject.toml
  394 +++ b/tests/fixtures/old_lock/pyproject.toml
  395 @@ -6,7 +6,7 @@ authors = ["Poetry Developer <developer@python-poetry.org>"]
  396  
  397  [tool.poetry.dependencies]
  398  python = "^3.8"
  399 -docker = "^4.3.1"
  400 +sampleproject = ">=1.3.1"
  401  
  402  [tool.poetry.dev-dependencies]
  403  
  404 diff --git a/tests/installation/test_chef.py b/tests/installation/test_chef.py
  405 index 9fcbbea1..4e59b608 100644
  406 --- a/tests/installation/test_chef.py
  407 +++ b/tests/installation/test_chef.py
  408 @@ -60,7 +60,7 @@ def test_get_cached_archives_for_link(config, mocker):
  409      }
  410  
  411  
  412 -def test_get_cache_directory_for_link(config):
  413 +def test_get_cache_directory_for_link(config, config_cache_dir):
  414      chef = Chef(
  415          config,
  416          MockEnv(
  417 @@ -71,8 +71,11 @@ def test_get_cache_directory_for_link(config):
  418      directory = chef.get_cache_directory_for_link(
  419          Link("https://files.python-poetry.org/poetry-1.1.0.tar.gz")
  420      )
  421 +
  422      expected = Path(
  423 -        "/foo/artifacts/ba/63/13/283a3b3b7f95f05e9e6f84182d276f7bb0951d5b0cc24422b33f7a4648"
  424 +        "{}/artifacts/ba/63/13/283a3b3b7f95f05e9e6f84182d276f7bb0951d5b0cc24422b33f7a4648".format(
  425 +            config_cache_dir.as_posix()
  426 +        )
  427      )
  428  
  429      assert expected == directory
  430 diff --git a/tests/installation/test_executor.py b/tests/installation/test_executor.py
  431 index bb659321..3dfd818b 100644
  432 --- a/tests/installation/test_executor.py
  433 +++ b/tests/installation/test_executor.py
  434 @@ -126,9 +126,11 @@ Package operations: 4 installs, 1 update, 1 removal
  435      assert 5 == len(env.executed)
  436  
  437  
  438 -def test_execute_shows_skipped_operations_if_verbose(config, pool, io):
  439 +def test_execute_shows_skipped_operations_if_verbose(
  440 +    config, pool, io, config_cache_dir
  441 +):
  442      config = Config()
  443 -    config.merge({"cache-dir": "/foo"})
  444 +    config.merge({"cache-dir": config_cache_dir.as_posix()})
  445  
  446      env = MockEnv()
  447      executor = Executor(env, pool, config, io)
  448 diff --git a/tests/masonry/builders/test_editable_builder.py b/tests/masonry/builders/test_editable_builder.py
  449 index daeff0e7..3bf1e59c 100644
  450 --- a/tests/masonry/builders/test_editable_builder.py
  451 +++ b/tests/masonry/builders/test_editable_builder.py
  452 @@ -176,9 +176,9 @@ if __name__ == '__main__':
  453  
  454  
  455  def test_builder_falls_back_on_setup_and_pip_for_packages_with_build_scripts(
  456 -    extended_poetry,
  457 +    extended_poetry, tmp_dir
  458  ):
  459 -    env = MockEnv(path=Path("/foo"))
  460 +    env = MockEnv(path=Path(tmp_dir) / "foo")
  461      builder = EditableBuilder(extended_poetry, env, NullIO())
  462  
  463      builder.build()
  464 @@ -219,8 +219,8 @@ def test_builder_installs_proper_files_when_packages_configured(
  465      assert len(paths) == len(expected)
  466  
  467  
  468 -def test_builder_should_execute_build_scripts(extended_without_setup_poetry):
  469 -    env = MockEnv(path=Path("/foo"))
  470 +def test_builder_should_execute_build_scripts(extended_without_setup_poetry, tmp_dir):
  471 +    env = MockEnv(path=Path(tmp_dir) / "foo")
  472      builder = EditableBuilder(extended_without_setup_poetry, env, NullIO())
  473  
  474      builder.build()
  475 diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py
  476 index cd5e1b9f..ad1e17f2 100644
  477 --- a/tests/utils/test_env.py
  478 +++ b/tests/utils/test_env.py
  479 @@ -634,7 +634,7 @@ def test_run_with_input_non_zero_return(tmp_dir, tmp_venv):
  480  
  481  
  482  def test_create_venv_tries_to_find_a_compatible_python_executable_using_generic_ones_first(
  483 -    manager, poetry, config, mocker
  484 +    manager, poetry, config, mocker, config_virtualenvs_path
  485  ):
  486      if "VIRTUAL_ENV" in os.environ:
  487          del os.environ["VIRTUAL_ENV"]
  488 @@ -654,12 +654,12 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_generic_
  489      manager.create_venv(NullIO())
  490  
  491      m.assert_called_with(
  492 -        Path("/foo/virtualenvs/{}-py3.7".format(venv_name)), executable="python3"
  493 +        config_virtualenvs_path / "{}-py3.7".format(venv_name), executable="python3"
  494      )
  495  
  496  
  497  def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific_ones(
  498 -    manager, poetry, config, mocker
  499 +    manager, poetry, config, mocker, config_virtualenvs_path
  500  ):
  501      if "VIRTUAL_ENV" in os.environ:
  502          del os.environ["VIRTUAL_ENV"]
  503 @@ -678,7 +678,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
  504      manager.create_venv(NullIO())
  505  
  506      m.assert_called_with(
  507 -        Path("/foo/virtualenvs/{}-py3.9".format(venv_name)), executable="python3.9"
  508 +        config_virtualenvs_path / "{}-py3.9".format(venv_name), executable="python3.9"
  509      )
  510  
  511  
  512 @@ -737,7 +737,7 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
  513  
  514  
  515  def test_create_venv_uses_patch_version_to_detect_compatibility(
  516 -    manager, poetry, config, mocker
  517 +    manager, poetry, config, mocker, config_virtualenvs_path
  518  ):
  519      if "VIRTUAL_ENV" in os.environ:
  520          del os.environ["VIRTUAL_ENV"]
  521 @@ -761,17 +761,14 @@ def test_create_venv_uses_patch_version_to_detect_compatibility(
  522  
  523      assert not check_output.called
  524      m.assert_called_with(
  525 -        Path(
  526 -            "/foo/virtualenvs/{}-py{}.{}".format(
  527 -                venv_name, version.major, version.minor
  528 -            )
  529 -        ),
  530 +        config_virtualenvs_path
  531 +        / "{}-py{}.{}".format(venv_name, version.major, version.minor),
  532          executable=None,
  533      )
  534  
  535  
  536  def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable(
  537 -    manager, poetry, config, mocker
  538 +    manager, poetry, config, mocker, config_virtualenvs_path
  539  ):
  540      if "VIRTUAL_ENV" in os.environ:
  541          del os.environ["VIRTUAL_ENV"]
  542 @@ -798,11 +795,8 @@ def test_create_venv_uses_patch_version_to_detect_compatibility_with_executable(
  543  
  544      assert check_output.called
  545      m.assert_called_with(
  546 -        Path(
  547 -            "/foo/virtualenvs/{}-py{}.{}".format(
  548 -                venv_name, version.major, version.minor - 1
  549 -            )
  550 -        ),
  551 +        config_virtualenvs_path
  552 +        / "{}-py{}.{}".format(venv_name, version.major, version.minor - 1),
  553          executable="python{}.{}".format(version.major, version.minor - 1),
  554      )
  555  
  556 -- 
  557 2.30.0

Generated by cgit