diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2017-09-03 19:57:54 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2017-09-03 20:01:45 -0400 |
commit | dcb24ad15465c266a3f258471766fbbe8fc8a42e (patch) | |
tree | 13123440610d78e398476a8ce1e8cc3d9f9ec72e /setuptools/tests/test_develop.py | |
parent | f14930e66601b462699c44384c482cd966f53b8f (diff) | |
parent | 1b192005562d5cf0de30c02154c58fd1dca577c8 (diff) | |
download | external_python_setuptools-dcb24ad15465c266a3f258471766fbbe8fc8a42e.tar.gz external_python_setuptools-dcb24ad15465c266a3f258471766fbbe8fc8a42e.tar.bz2 external_python_setuptools-dcb24ad15465c266a3f258471766fbbe8fc8a42e.zip |
Merge branch 'master' into drop-py26
Diffstat (limited to 'setuptools/tests/test_develop.py')
-rw-r--r-- | setuptools/tests/test_develop.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 4cf483f2..ad7cfa05 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -1,17 +1,23 @@ """develop tests """ + +from __future__ import absolute_import, unicode_literals + import os import site import sys import io +import subprocess from setuptools.extern import six +from setuptools.command import test import pytest from setuptools.command.develop import develop from setuptools.dist import Distribution from . import contexts +from . import namespaces SETUP_PY = """\ from setuptools import setup @@ -114,3 +120,72 @@ class TestDevelop: cmd.install_dir = tmpdir cmd.run() # assert '0.0' not in foocmd_text + + +class TestResolver: + """ + TODO: These tests were written with a minimal understanding + of what _resolve_setup_path is intending to do. Come up with + more meaningful cases that look like real-world scenarios. + """ + def test_resolve_setup_path_cwd(self): + assert develop._resolve_setup_path('.', '.', '.') == '.' + + def test_resolve_setup_path_one_dir(self): + assert develop._resolve_setup_path('pkgs', '.', 'pkgs') == '../' + + def test_resolve_setup_path_one_dir_trailing_slash(self): + assert develop._resolve_setup_path('pkgs/', '.', 'pkgs') == '../' + + +class TestNamespaces: + + @staticmethod + def install_develop(src_dir, target): + + develop_cmd = [ + sys.executable, + 'setup.py', + 'develop', + '--install-dir', str(target), + ] + with src_dir.as_cwd(): + 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") + def test_namespace_package_importable(self, tmpdir): + """ + Installing two packages sharing the same namespace, one installed + naturally using pip or `--single-version-externally-managed` + and the other installed using `develop` should leave the namespace + in tact and both packages reachable by import. + """ + pkg_A = namespaces.build_namespace_package(tmpdir, 'myns.pkgA') + pkg_B = namespaces.build_namespace_package(tmpdir, 'myns.pkgB') + target = tmpdir / 'packages' + # use pip to install to the target directory + install_cmd = [ + 'pip', + 'install', + str(pkg_A), + '-t', str(target), + ] + subprocess.check_call(install_cmd) + self.install_develop(pkg_B, target) + namespaces.make_site_dir(target) + try_import = [ + sys.executable, + '-c', 'import myns.pkgA; import myns.pkgB', + ] + 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', + ] + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(pkg_resources_imp) |