diff options
-rw-r--r-- | CHANGES.rst | 8 | ||||
-rw-r--r-- | setuptools/tests/test_develop.py | 12 | ||||
-rw-r--r-- | setuptools/tests/test_namespaces.py | 17 |
3 files changed, 24 insertions, 13 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 1a57ad55..793c4c33 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,11 @@ +v32.1.4 +------- + +* #884: Restore support for running the tests under + `pytest-runner <https://github.com/pytest-dev/pytest-runner>`_ + by ensuring that PYTHONPATH is honored in tests invoking + a subprocess. + v32.1.3 ------- diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 430a07e6..5dd72aae 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -10,6 +10,7 @@ import io import subprocess from setuptools.extern import six +from setuptools.command import test import pytest @@ -132,9 +133,9 @@ class TestNamespaces: 'develop', '--install-dir', str(target), ] - env = dict(PYTHONPATH=str(target)) with src_dir.as_cwd(): - subprocess.check_call(develop_cmd, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(develop_cmd) @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), reason="https://github.com/pypa/setuptools/issues/851") @@ -162,12 +163,13 @@ class TestNamespaces: sys.executable, '-c', 'import myns.pkgA; import myns.pkgB', ] - env = dict(PYTHONPATH=str(target)) - subprocess.check_call(try_import, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(try_import) # additionally ensure that pkg_resources import works pkg_resources_imp = [ sys.executable, '-c', 'import pkg_resources', ] - subprocess.check_call(pkg_resources_imp, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(pkg_resources_imp) diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 451df3c4..721cad1e 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -7,6 +7,7 @@ import subprocess import pytest from . import namespaces +from setuptools.command import test class TestNamespaces: @@ -27,7 +28,6 @@ class TestNamespaces: site_packages = tmpdir / 'site-packages' path_packages = tmpdir / 'path-packages' targets = site_packages, path_packages - python_path = os.pathsep.join(map(str, targets)) # use pip to install to the target directory install_cmd = [ 'pip', @@ -48,8 +48,8 @@ class TestNamespaces: sys.executable, '-c', 'import myns.pkgA; import myns.pkgB', ] - env = dict(PYTHONPATH=python_path) - subprocess.check_call(try_import, env=env) + with test.test.paths_on_pythonpath(map(str, targets)): + subprocess.check_call(try_import) @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), reason="https://github.com/pypa/setuptools/issues/851") @@ -61,20 +61,21 @@ class TestNamespaces: pkg = namespaces.build_namespace_package(tmpdir, 'myns.pkgA') target = tmpdir / 'packages' target.mkdir() - env = dict(PYTHONPATH=str(target)) install_cmd = [ sys.executable, '-m', 'easy_install', '-d', str(target), str(pkg), ] - subprocess.check_call(install_cmd, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(install_cmd) namespaces.make_site_dir(target) try_import = [ sys.executable, '-c', 'import pkg_resources', ] - subprocess.check_call(try_import, env=env) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(try_import) @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), reason="https://github.com/pypa/setuptools/issues/851") @@ -100,5 +101,5 @@ class TestNamespaces: sys.executable, '-c', 'import pkg_resources; import myns.pkgA', ] - env = dict(PYTHONPATH=str(target)) - subprocess.check_call(pkg_resources_imp, env=env, cwd=str(pkg_A)) + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(pkg_resources_imp, cwd=str(pkg_A)) |