summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setuptools/tests/namespaces.py13
-rw-r--r--setuptools/tests/test_develop.py4
-rw-r--r--setuptools/tests/test_namespaces.py7
3 files changed, 18 insertions, 6 deletions
diff --git a/setuptools/tests/namespaces.py b/setuptools/tests/namespaces.py
index ef5ecdad..72a7db5c 100644
--- a/setuptools/tests/namespaces.py
+++ b/setuptools/tests/namespaces.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import, unicode_literals
+import os
import textwrap
@@ -40,3 +41,15 @@ def make_site_dir(target):
target_str = str(target)
tmpl = '__import__("site").addsitedir({target_str!r})'
sc.write_text(tmpl.format(**locals()), encoding='utf-8')
+
+
+def build_pythonpath(*paths):
+ """
+ Create a PYTHONPATH value for the indicated paths, casting
+ them to strings, but also injecting the CWD ahead of the
+ values to ensure that this setuptools is used if the tests
+ are invoked without this setuptools being installed.
+ See #884.
+ """
+ paths = (os.getcwd(),) + paths
+ return os.pathsep.join(map(str, paths))
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py
index 430a07e6..9460b9bf 100644
--- a/setuptools/tests/test_develop.py
+++ b/setuptools/tests/test_develop.py
@@ -132,7 +132,7 @@ class TestNamespaces:
'develop',
'--install-dir', str(target),
]
- env = dict(PYTHONPATH=str(target))
+ env = dict(PYTHONPATH=namespaces.build_pythonpath(target))
with src_dir.as_cwd():
subprocess.check_call(develop_cmd, env=env)
@@ -162,7 +162,7 @@ class TestNamespaces:
sys.executable,
'-c', 'import myns.pkgA; import myns.pkgB',
]
- env = dict(PYTHONPATH=str(target))
+ env = dict(PYTHONPATH=namespaces.build_pythonpath(target))
subprocess.check_call(try_import, env=env)
# additionally ensure that pkg_resources import works
diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py
index 451df3c4..cf103733 100644
--- a/setuptools/tests/test_namespaces.py
+++ b/setuptools/tests/test_namespaces.py
@@ -26,8 +26,7 @@ class TestNamespaces:
pkg_B = namespaces.build_namespace_package(tmpdir, 'myns.pkgB')
site_packages = tmpdir / 'site-packages'
path_packages = tmpdir / 'path-packages'
- targets = site_packages, path_packages
- python_path = os.pathsep.join(map(str, targets))
+ python_path = namespaces.build_pythonpath(site_packages, path_packages)
# use pip to install to the target directory
install_cmd = [
'pip',
@@ -61,7 +60,7 @@ class TestNamespaces:
pkg = namespaces.build_namespace_package(tmpdir, 'myns.pkgA')
target = tmpdir / 'packages'
target.mkdir()
- env = dict(PYTHONPATH=str(target))
+ env = dict(PYTHONPATH=namespaces.build_pythonpath(target))
install_cmd = [
sys.executable,
'-m', 'easy_install',
@@ -100,5 +99,5 @@ class TestNamespaces:
sys.executable,
'-c', 'import pkg_resources; import myns.pkgA',
]
- env = dict(PYTHONPATH=str(target))
+ env = dict(PYTHONPATH=namespaces.build_pythonpath(target))
subprocess.check_call(pkg_resources_imp, env=env, cwd=str(pkg_A))