diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-22 09:31:40 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-12-22 09:31:40 -0500 |
commit | 7a1c700e16523ad07532bea2ed87718fe29d3595 (patch) | |
tree | 49337bc88735e3e12e282a1a353d45898a8f082c /setuptools/tests/test_namespaces.py | |
parent | 5d4b2b691fea992ec47132ba2b01ebd396fe7216 (diff) | |
download | python-setuptools-git-7a1c700e16523ad07532bea2ed87718fe29d3595.tar.gz |
Re-use test.paths_on_pythonpath to extend the PYTHONPATH variable rather than erasing it. When tests are run under pytest-runner (or other setup.py test invocations), the PYTHONPATH is carefully curated to include dependencies and the project under test. Overwriting PYTHONPATH will break tests in those environments. Fixes #884.
Diffstat (limited to 'setuptools/tests/test_namespaces.py')
-rw-r--r-- | setuptools/tests/test_namespaces.py | 17 |
1 files changed, 9 insertions, 8 deletions
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)) |