19
19
import pathlib
20
20
import warnings
21
21
from collections import namedtuple
22
+ from pathlib import Path
22
23
23
24
import pytest
24
25
from jaraco import path
40
41
from . import contexts
41
42
from .textwrap import DALS
42
43
43
- import py
44
-
45
44
46
45
@pytest .fixture (autouse = True )
47
46
def pip_disable_index (monkeypatch ):
@@ -1113,7 +1112,7 @@ def test_use_correct_python_version_string(tmpdir, tmpdir_cwd, monkeypatch):
1113
1112
assert cmd .config_vars ['py_version_nodot' ] == '310'
1114
1113
1115
1114
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 ):
1117
1116
''' `setup.py develop` should honor `--user` even under build isolation'''
1118
1117
1119
1118
# == Arrange ==
@@ -1128,27 +1127,28 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmpdir):
1128
1127
# 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
1129
1128
# 2. We are going to force `site` to update site.USER_BASE and site.USER_SITE
1130
1129
# To point inside our new home
1131
- monkeypatch .setenv ('HOME' , str (tmpdir / 'home' ))
1130
+ monkeypatch .setenv ('HOME' , str (tmp_path / 'home' ))
1132
1131
monkeypatch .setattr ('site.USER_BASE' , None )
1133
1132
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 )
1136
1135
1137
- sys_prefix = (tmpdir / 'sys_prefix' ).ensure_dir ()
1136
+ sys_prefix = (tmp_path / 'sys_prefix' )
1137
+ sys_prefix .mkdir (parents = True , exist_ok = True )
1138
1138
monkeypatch .setattr ('sys.prefix' , str (sys_prefix ))
1139
1139
1140
1140
# == Sanity check ==
1141
- assert sys_prefix .listdir ( ) == []
1142
- assert user_site .listdir ( ) == []
1141
+ assert list ( sys_prefix .glob ( "*" ) ) == []
1142
+ assert list ( user_site .glob ( "*" ) ) == []
1143
1143
1144
1144
# == Act ==
1145
1145
run_setup ('setup.py' , ['develop' , '--user' ])
1146
1146
1147
1147
# == Assert ==
1148
1148
# Should not install to sys.prefix
1149
- assert sys_prefix .listdir ( ) == []
1149
+ assert list ( sys_prefix .glob ( "*" ) ) == []
1150
1150
# 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 ( "*" )}
1152
1152
# sometimes easy-install.pth is created and sometimes not
1153
1153
installed = installed - {"easy-install.pth" }
1154
1154
assert installed == {'UNKNOWN.egg-link' }
0 commit comments