Skip to content

Commit c2f4907

Browse files
committed
Replace direct usage of the py library
According to https://pypi.org/project/py/, this library is in maintenance mode and should not be used in new code.
1 parent a28da5f commit c2f4907

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

setuptools/tests/test_easy_install.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import pathlib
2020
import warnings
2121
from collections import namedtuple
22+
from pathlib import Path
2223

2324
import pytest
2425
from jaraco import path
@@ -40,8 +41,6 @@
4041
from . import contexts
4142
from .textwrap import DALS
4243

43-
import py
44-
4544

4645
@pytest.fixture(autouse=True)
4746
def pip_disable_index(monkeypatch):
@@ -1113,7 +1112,7 @@ def test_use_correct_python_version_string(tmpdir, tmpdir_cwd, monkeypatch):
11131112
assert cmd.config_vars['py_version_nodot'] == '310'
11141113

11151114

1116-
def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmpdir):
1115+
def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmp_path):
11171116
''' `setup.py develop` should honor `--user` even under build isolation'''
11181117

11191118
# == Arrange ==
@@ -1128,27 +1127,28 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmpdir):
11281127
# it will `makedirs("/home/user/.pyenv/versions/3.9.10 /home/user/.pyenv/versions/3.9.10/lib /home/user/.pyenv/versions/3.9.10/lib/python3.9 /home/user/.pyenv/versions/3.9.10/lib/python3.9/lib-dynload")`` # noqa: E501
11291128
# 2. We are going to force `site` to update site.USER_BASE and site.USER_SITE
11301129
# To point inside our new home
1131-
monkeypatch.setenv('HOME', str(tmpdir / 'home'))
1130+
monkeypatch.setenv('HOME', str(tmp_path / 'home'))
11321131
monkeypatch.setattr('site.USER_BASE', None)
11331132
monkeypatch.setattr('site.USER_SITE', None)
1134-
user_site = py.path.local(site.getusersitepackages())
1135-
user_site.ensure_dir()
1133+
user_site = Path(site.getusersitepackages())
1134+
user_site.mkdir(parents=True, exist_ok=True)
11361135

1137-
sys_prefix = (tmpdir / 'sys_prefix').ensure_dir()
1136+
sys_prefix = (tmp_path / 'sys_prefix')
1137+
sys_prefix.mkdir(parents=True, exist_ok=True)
11381138
monkeypatch.setattr('sys.prefix', str(sys_prefix))
11391139

11401140
# == Sanity check ==
1141-
assert sys_prefix.listdir() == []
1142-
assert user_site.listdir() == []
1141+
assert list(sys_prefix.glob("*")) == []
1142+
assert list(user_site.glob("*")) == []
11431143

11441144
# == Act ==
11451145
run_setup('setup.py', ['develop', '--user'])
11461146

11471147
# == Assert ==
11481148
# Should not install to sys.prefix
1149-
assert sys_prefix.listdir() == []
1149+
assert list(sys_prefix.glob("*")) == []
11501150
# Should install to user site
1151-
installed = {f.basename for f in user_site.listdir()}
1151+
installed = {f.name for f in user_site.glob("*")}
11521152
# sometimes easy-install.pth is created and sometimes not
11531153
installed = installed - {"easy-install.pth"}
11541154
assert installed == {'UNKNOWN.egg-link'}

0 commit comments

Comments
 (0)