Skip to content

Commit b4d8e47

Browse files
committed
Add test capturing missed expectation. Ref #2612.
1 parent 8230bbf commit b4d8e47

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

setuptools/tests/fixtures.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import contextlib
22
import sys
33
import shutil
4+
import subprocess
45

56
import pytest
67

@@ -58,3 +59,16 @@ def workaround_xdist_376(request):
5859

5960
with contextlib.suppress(ValueError):
6061
sys.path.remove('')
62+
63+
64+
@pytest.fixture
65+
def sample_project(tmp_path):
66+
"""
67+
Clone the 'sampleproject' and return a path to it.
68+
"""
69+
cmd = ['git', 'clone', 'https://github.com/pypa/sampleproject']
70+
try:
71+
subprocess.check_call(cmd, cwd=str(tmp_path))
72+
except Exception:
73+
pytest.skip("Unable to clone sampleproject")
74+
return tmp_path / 'sampleproject'

setuptools/tests/test_develop.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io
88
import subprocess
99
import platform
10+
import pathlib
1011

1112
from setuptools.command import test
1213

@@ -199,3 +200,32 @@ def test_namespace_package_importable(self, tmpdir):
199200
]
200201
with test.test.paths_on_pythonpath([str(target)]):
201202
subprocess.check_call(pkg_resources_imp)
203+
204+
@pytest.mark.xfail(reason="#2612")
205+
def test_editable_prefix(self, tmp_path, sample_project):
206+
"""
207+
Editable install to a prefix should be discoverable.
208+
"""
209+
prefix = tmp_path / 'prefix'
210+
prefix.mkdir()
211+
212+
cmd = [
213+
sys.executable,
214+
'-m', 'pip',
215+
'install',
216+
'-e', str(sample_project),
217+
'--prefix', str(prefix),
218+
]
219+
subprocess.check_call(cmd)
220+
221+
# now run 'sample' with the prefix on the PYTHONPATH
222+
site_packages = prefix / next(
223+
pathlib.Path(path).relative_to(sys.prefix)
224+
for path in sys.path
225+
if 'site-packages' in path
226+
and path.startswith(sys.prefix)
227+
)
228+
env = dict(PYTHONPATH=site_packages)
229+
bin = 'Scripts' if platform.system() == 'Windows' else 'bin'
230+
sample = prefix / bin / 'sample'
231+
subprocess.check_call([sample], env=env)

0 commit comments

Comments
 (0)