From cb75964e09d2441e0d00ee3b5861f8412a3a672d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 13 Nov 2016 10:53:34 -0500 Subject: Add test capturing (failing) expectation. Ref #805. --- setuptools/tests/test_namespaces.py | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 setuptools/tests/test_namespaces.py (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py new file mode 100644 index 00000000..f90c25cf --- /dev/null +++ b/setuptools/tests/test_namespaces.py @@ -0,0 +1,83 @@ +from __future__ import absolute_import + +import os +import textwrap +import sys +import subprocess + + +class TestNamespaces: + @staticmethod + def build_namespace_package(tmpdir, name): + src_dir = tmpdir / name + src_dir.mkdir() + setup_py = src_dir / 'setup.py' + namespace, sep, rest = name.partition('.') + script = textwrap.dedent(""" + import setuptools + setuptools.setup( + name={name!r}, + version="1.0", + namespace_packages=[{namespace!r}], + packages=[{namespace!r}], + ) + """).format(**locals()) + setup_py.write_text(script, encoding='utf-8') + ns_pkg_dir = src_dir / namespace + ns_pkg_dir.mkdir() + pkg_init = ns_pkg_dir / '__init__.py' + tmpl = '__import__("pkg_resources").declare_namespace({namespace!r})' + decl = tmpl.format(**locals()) + pkg_init.write_text(decl, encoding='utf-8') + pkg_mod = ns_pkg_dir / (rest + '.py') + some_functionality = 'name = {rest!r}'.format(**locals()) + pkg_mod.write_text(some_functionality, encoding='utf-8') + return src_dir + + @staticmethod + def make_site_dir(target): + """ + Add a sitecustomize.py module in target to cause + target to be added to site dirs such that .pth files + are processed there. + """ + sc = target / 'sitecustomize.py' + target_str = str(target) + tmpl = '__import__("site").addsitedir({target_str!r})' + sc.write_text(tmpl.format(**locals()), encoding='utf-8') + + def test_mixed_site_and_non_site(self, tmpdir): + """ + Installing two packages sharing the same namespace, one installed + to a site dir and the other installed just to a path on PYTHONPATH + should leave the namespace in tact and both packages reachable by + import. + """ + pkg_A = self.build_namespace_package(tmpdir, 'myns.pkgA') + pkg_B = self.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)) + # use pip to install to the target directory + install_cmd = [ + 'pip', + 'install', + str(pkg_A), + '-t', str(site_packages), + ] + subprocess.check_call(install_cmd) + self.make_site_dir(site_packages) + install_cmd = [ + 'pip', + 'install', + str(pkg_B), + '-t', str(path_packages), + ] + subprocess.check_call(install_cmd) + try_import = [ + sys.executable, + '-c', 'import myns.pkgA; import myns.pkgB', + ] + env = dict(PYTHONPATH=python_path) + subprocess.check_call(try_import, env=env) -- cgit v1.2.1 From 5d78aeb98a5d2b1c366421e68162d9d46de45502 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 13 Nov 2016 11:33:00 -0500 Subject: Fix test failures on Python 2 and suppress test failures when PEP 420 is not available. Ref #805. --- setuptools/tests/test_namespaces.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index f90c25cf..ad3c78b8 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -1,10 +1,12 @@ -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import textwrap import sys import subprocess +import pytest + class TestNamespaces: @staticmethod @@ -46,6 +48,8 @@ class TestNamespaces: tmpl = '__import__("site").addsitedir({target_str!r})' sc.write_text(tmpl.format(**locals()), encoding='utf-8') + @pytest.mark.xfail(sys.version_info < (3, 3), + reason="Requires PEP 420") def test_mixed_site_and_non_site(self, tmpdir): """ Installing two packages sharing the same namespace, one installed -- cgit v1.2.1 From ed765324e72e7e6be1f84778eaa7496df0e7a381 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 13 Nov 2016 11:39:11 -0500 Subject: Extract namespace support functionality into a separate module. --- setuptools/tests/test_namespaces.py | 47 ++++--------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index ad3c78b8..c148577d 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -1,52 +1,15 @@ from __future__ import absolute_import, unicode_literals import os -import textwrap import sys import subprocess import pytest +from . import namespaces -class TestNamespaces: - @staticmethod - def build_namespace_package(tmpdir, name): - src_dir = tmpdir / name - src_dir.mkdir() - setup_py = src_dir / 'setup.py' - namespace, sep, rest = name.partition('.') - script = textwrap.dedent(""" - import setuptools - setuptools.setup( - name={name!r}, - version="1.0", - namespace_packages=[{namespace!r}], - packages=[{namespace!r}], - ) - """).format(**locals()) - setup_py.write_text(script, encoding='utf-8') - ns_pkg_dir = src_dir / namespace - ns_pkg_dir.mkdir() - pkg_init = ns_pkg_dir / '__init__.py' - tmpl = '__import__("pkg_resources").declare_namespace({namespace!r})' - decl = tmpl.format(**locals()) - pkg_init.write_text(decl, encoding='utf-8') - pkg_mod = ns_pkg_dir / (rest + '.py') - some_functionality = 'name = {rest!r}'.format(**locals()) - pkg_mod.write_text(some_functionality, encoding='utf-8') - return src_dir - @staticmethod - def make_site_dir(target): - """ - Add a sitecustomize.py module in target to cause - target to be added to site dirs such that .pth files - are processed there. - """ - sc = target / 'sitecustomize.py' - target_str = str(target) - tmpl = '__import__("site").addsitedir({target_str!r})' - sc.write_text(tmpl.format(**locals()), encoding='utf-8') +class TestNamespaces: @pytest.mark.xfail(sys.version_info < (3, 3), reason="Requires PEP 420") @@ -57,8 +20,8 @@ class TestNamespaces: should leave the namespace in tact and both packages reachable by import. """ - pkg_A = self.build_namespace_package(tmpdir, 'myns.pkgA') - pkg_B = self.build_namespace_package(tmpdir, 'myns.pkgB') + pkg_A = namespaces.build_namespace_package(tmpdir, 'myns.pkgA') + pkg_B = namespaces.build_namespace_package(tmpdir, 'myns.pkgB') site_packages = tmpdir / 'site-packages' path_packages = tmpdir / 'path-packages' targets = site_packages, path_packages @@ -71,7 +34,7 @@ class TestNamespaces: '-t', str(site_packages), ] subprocess.check_call(install_cmd) - self.make_site_dir(site_packages) + namespaces.make_site_dir(site_packages) install_cmd = [ 'pip', 'install', -- cgit v1.2.1 From e8d53c0b830744a3cec9c0080293c39dfbf5ac72 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 18 Nov 2016 16:07:10 -0500 Subject: Skip failing test on appveyor until the cause can be uncovered. Ref #851. --- setuptools/tests/test_namespaces.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index c148577d..21fd69e7 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -13,6 +13,8 @@ class TestNamespaces: @pytest.mark.xfail(sys.version_info < (3, 3), reason="Requires PEP 420") + @pytest.mark.skipif('os.environ.get("APPVEYOR")', + reason="https://github.com/pypa/setuptools/issues/851") def test_mixed_site_and_non_site(self, tmpdir): """ Installing two packages sharing the same namespace, one installed -- cgit v1.2.1 From a83ae992278916ade263379f2d7adc56a4539ff4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 29 Nov 2016 18:20:05 -0600 Subject: Evaluate the expression directly. Workaround for #860. --- setuptools/tests/test_namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 21fd69e7..2d44ad86 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -13,7 +13,7 @@ class TestNamespaces: @pytest.mark.xfail(sys.version_info < (3, 3), reason="Requires PEP 420") - @pytest.mark.skipif('os.environ.get("APPVEYOR")', + @pytest.mark.skipif(os.environ.get("APPVEYOR"), reason="https://github.com/pypa/setuptools/issues/851") def test_mixed_site_and_non_site(self, tmpdir): """ -- cgit v1.2.1 From d42c2ace9c89dccf0076c17d33f7202e05f97bc0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Dec 2016 11:30:26 -0500 Subject: cast the value to a bool so pytest doesn't try to eval it --- setuptools/tests/test_namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 2d44ad86..28c5e9de 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -13,7 +13,7 @@ class TestNamespaces: @pytest.mark.xfail(sys.version_info < (3, 3), reason="Requires PEP 420") - @pytest.mark.skipif(os.environ.get("APPVEYOR"), + @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), reason="https://github.com/pypa/setuptools/issues/851") def test_mixed_site_and_non_site(self, tmpdir): """ -- cgit v1.2.1 From 230ffaafd061b42f8674b6b6b75ed8133e8d6934 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 11 Dec 2016 16:18:29 -0500 Subject: Expect failure on Python 3.4 and earlier as module_from_spec isn't available. Ref #250. --- setuptools/tests/test_namespaces.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 28c5e9de..e7fa4ee6 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -11,8 +11,8 @@ from . import namespaces class TestNamespaces: - @pytest.mark.xfail(sys.version_info < (3, 3), - reason="Requires PEP 420") + @pytest.mark.xfail(sys.version_info < (3, 5), + reason="Requires importlib.util.module_from_spec") @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), reason="https://github.com/pypa/setuptools/issues/851") def test_mixed_site_and_non_site(self, tmpdir): -- cgit v1.2.1 From 357b7c659b6893dec4145d492084217b9317bca1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 12 Dec 2016 19:45:51 -0500 Subject: Add test attempting to capture failure, but it passes. Ref #885. --- setuptools/tests/test_namespaces.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index e7fa4ee6..2aefb487 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -50,3 +50,26 @@ class TestNamespaces: ] env = dict(PYTHONPATH=python_path) subprocess.check_call(try_import, env=env) + + def test_pkg_resources_import(self, tmpdir): + """ + Ensure that a namespace package doesn't break on import + of pkg_resources. + """ + 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) + namespaces.make_site_dir(target) + try_import = [ + sys.executable, + '-c', 'import pkg_resources', + ] + subprocess.check_call(try_import, env=env) -- cgit v1.2.1 From bffd26f485964e1cfb881ccf85179b2947d5e734 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 13 Dec 2016 21:06:00 -0500 Subject: Add test capturing expectation when a package is both installed and in the current working directory. Ref #885. --- setuptools/tests/test_namespaces.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 2aefb487..5199129e 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -73,3 +73,30 @@ class TestNamespaces: '-c', 'import pkg_resources', ] subprocess.check_call(try_import, env=env) + + @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), + reason="https://github.com/pypa/setuptools/issues/851") + def test_namespace_package_installed_and_cwd(self, tmpdir): + """ + Installing a namespace packages but also having it in the current + working directory, only one version should take precedence. + """ + pkg_A = namespaces.build_namespace_package(tmpdir, 'myns.pkgA') + 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) + namespaces.make_site_dir(target) + + # ensure that package imports and pkg_resources imports + pkg_resources_imp = [ + 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)) -- cgit v1.2.1 From 3e05a9630ff0e0596a539d4b6d24f97d3fb987f8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 13 Dec 2016 21:17:10 -0500 Subject: Skip again on appveyor --- setuptools/tests/test_namespaces.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 5199129e..451df3c4 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -51,6 +51,8 @@ class TestNamespaces: env = dict(PYTHONPATH=python_path) subprocess.check_call(try_import, env=env) + @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), + reason="https://github.com/pypa/setuptools/issues/851") def test_pkg_resources_import(self, tmpdir): """ Ensure that a namespace package doesn't break on import -- cgit v1.2.1 From 7a1c700e16523ad07532bea2ed87718fe29d3595 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 22 Dec 2016 09:31:40 -0500 Subject: 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. --- setuptools/tests/test_namespaces.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') 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)) -- cgit v1.2.1 From ee40d9fffac9c13ecfe9a427872adeeaedc57778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 20 Sep 2017 14:03:27 +0200 Subject: Tests: Run `python -m pip` instead of plain `pip` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to run the testsuite on systems where `/usr/bin/pip` is a specific Python version, but the tests are run on a different one. For example in Fedora RPM, when the Python 3 tests are invoked, they should use Python 3 pip, not Python 2 `/usr/bin/pip`. Unlike other approaches, like using `pip2`/`pip3` which is currently done in Fedora RPM (downstream patch), this way it Works Everywhereâ„¢ and the downstream patch can be dropped. See https://src.fedoraproject.org/rpms/python-setuptools/blob/54eaa03a4dc97f93a5e4c92c55e580a4ab55a058/f/0001-Run-test-on-a-version-specific-pip.patch --- setuptools/tests/test_namespaces.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 721cad1e..14759e66 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -30,6 +30,8 @@ class TestNamespaces: targets = site_packages, path_packages # use pip to install to the target directory install_cmd = [ + sys.executable, + '-m', 'pip', 'install', str(pkg_A), @@ -38,6 +40,8 @@ class TestNamespaces: subprocess.check_call(install_cmd) namespaces.make_site_dir(site_packages) install_cmd = [ + sys.executable, + '-m', 'pip', 'install', str(pkg_B), @@ -88,6 +92,8 @@ class TestNamespaces: target = tmpdir / 'packages' # use pip to install to the target directory install_cmd = [ + sys.executable, + '-m', 'pip', 'install', str(pkg_A), -- cgit v1.2.1 From 7ea8086d35b6e072c8deae6de54c55f0582161e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 20 Sep 2017 14:52:48 +0200 Subject: Tests: Run `python -m pip.__main__` to support Python 2.6 See https://bugs.python.org/issue2751 --- setuptools/tests/test_namespaces.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 14759e66..1ac1b35e 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -32,7 +32,7 @@ class TestNamespaces: install_cmd = [ sys.executable, '-m', - 'pip', + 'pip.__main__', 'install', str(pkg_A), '-t', str(site_packages), @@ -42,7 +42,7 @@ class TestNamespaces: install_cmd = [ sys.executable, '-m', - 'pip', + 'pip.__main__', 'install', str(pkg_B), '-t', str(path_packages), @@ -94,7 +94,7 @@ class TestNamespaces: install_cmd = [ sys.executable, '-m', - 'pip', + 'pip.__main__', 'install', str(pkg_A), '-t', str(target), -- cgit v1.2.1 From 776096522af8d8320b879571ded2b1c43242c0da Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Wed, 27 Jun 2018 21:32:11 +0300 Subject: always process module.__path__ for namespace packages, fixes #1321 --- setuptools/tests/test_namespaces.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 1ac1b35e..00ec75b4 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -109,3 +109,34 @@ class TestNamespaces: ] with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp, cwd=str(pkg_A)) + + @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), + reason="https://github.com/pypa/setuptools/issues/851") + def test_packages_in_the_sampe_namespace_installed_and_cwd(self, tmpdir): + """ + Installing one namespace package and also have another in the same + namespace in the current working directory, both of them must be + importable. + """ + 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 = [ + sys.executable, + '-m', + 'pip.__main__', + 'install', + str(pkg_A), + '-t', str(target), + ] + subprocess.check_call(install_cmd) + namespaces.make_site_dir(target) + + # ensure that all packages import and pkg_resources imports + pkg_resources_imp = [ + sys.executable, + '-c', 'import pkg_resources; import myns.pkgA; import myns.pkgB', + ] + with test.test.paths_on_pythonpath([str(target)]): + subprocess.check_call(pkg_resources_imp, cwd=str(pkg_B)) -- cgit v1.2.1 From d2346c91804333b29fe63b8e1414cd764eb1ef5f Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 17 Aug 2018 17:36:20 +0300 Subject: xfail namespace packages tests on appveyor instead of skipping them --- setuptools/tests/test_namespaces.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 00ec75b4..52ac6a68 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -14,8 +14,10 @@ class TestNamespaces: @pytest.mark.xfail(sys.version_info < (3, 5), reason="Requires importlib.util.module_from_spec") - @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), - reason="https://github.com/pypa/setuptools/issues/851") + @pytest.mark.xfail( + os.environ.get("APPVEYOR"), + reason="https://github.com/pypa/setuptools/issues/851", + ) def test_mixed_site_and_non_site(self, tmpdir): """ Installing two packages sharing the same namespace, one installed @@ -55,8 +57,10 @@ class TestNamespaces: 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") + @pytest.mark.xfail( + os.environ.get("APPVEYOR"), + reason="https://github.com/pypa/setuptools/issues/851", + ) def test_pkg_resources_import(self, tmpdir): """ Ensure that a namespace package doesn't break on import @@ -81,8 +85,10 @@ class TestNamespaces: 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") + @pytest.mark.xfail( + os.environ.get("APPVEYOR"), + reason="https://github.com/pypa/setuptools/issues/851", + ) def test_namespace_package_installed_and_cwd(self, tmpdir): """ Installing a namespace packages but also having it in the current @@ -110,8 +116,10 @@ class TestNamespaces: with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp, cwd=str(pkg_A)) - @pytest.mark.skipif(bool(os.environ.get("APPVEYOR")), - reason="https://github.com/pypa/setuptools/issues/851") + @pytest.mark.xfail( + os.environ.get("APPVEYOR"), + reason="https://github.com/pypa/setuptools/issues/851", + ) def test_packages_in_the_sampe_namespace_installed_and_cwd(self, tmpdir): """ Installing one namespace package and also have another in the same -- cgit v1.2.1 From 1fc75056079f49d980dd664222bae47a713906ca Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 17 Aug 2018 17:38:22 +0300 Subject: change formatting to fix flake8 warning --- setuptools/tests/test_namespaces.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 52ac6a68..839f5651 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -12,8 +12,10 @@ from setuptools.command import test class TestNamespaces: - @pytest.mark.xfail(sys.version_info < (3, 5), - reason="Requires importlib.util.module_from_spec") + @pytest.mark.xfail( + sys.version_info < (3, 5), + reason="Requires importlib.util.module_from_spec", + ) @pytest.mark.xfail( os.environ.get("APPVEYOR"), reason="https://github.com/pypa/setuptools/issues/851", -- cgit v1.2.1 From 0553c91f1c08d0426574bc996e377706a6df3e1a Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Tue, 21 Aug 2018 14:01:26 +0300 Subject: remove xfail for namespace tests that actually pass in AppVeyor --- setuptools/tests/test_namespaces.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 839f5651..f2acff84 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -59,10 +59,6 @@ class TestNamespaces: with test.test.paths_on_pythonpath(map(str, targets)): subprocess.check_call(try_import) - @pytest.mark.xfail( - os.environ.get("APPVEYOR"), - reason="https://github.com/pypa/setuptools/issues/851", - ) def test_pkg_resources_import(self, tmpdir): """ Ensure that a namespace package doesn't break on import @@ -87,10 +83,6 @@ class TestNamespaces: with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(try_import) - @pytest.mark.xfail( - os.environ.get("APPVEYOR"), - reason="https://github.com/pypa/setuptools/issues/851", - ) def test_namespace_package_installed_and_cwd(self, tmpdir): """ Installing a namespace packages but also having it in the current @@ -118,11 +110,7 @@ class TestNamespaces: with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(pkg_resources_imp, cwd=str(pkg_A)) - @pytest.mark.xfail( - os.environ.get("APPVEYOR"), - reason="https://github.com/pypa/setuptools/issues/851", - ) - def test_packages_in_the_sampe_namespace_installed_and_cwd(self, tmpdir): + def test_packages_in_the_same_namespace_installed_and_cwd(self, tmpdir): """ Installing one namespace package and also have another in the same namespace in the current working directory, both of them must be -- cgit v1.2.1 From ec1a8f60134fb409c9b747cb15e0b5efbd519874 Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Tue, 21 Aug 2018 19:48:22 +0300 Subject: remove xfail for AppVeyor from namespace tests entirely --- setuptools/tests/test_namespaces.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index f2acff84..da19bd79 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -16,10 +16,6 @@ class TestNamespaces: sys.version_info < (3, 5), reason="Requires importlib.util.module_from_spec", ) - @pytest.mark.xfail( - os.environ.get("APPVEYOR"), - reason="https://github.com/pypa/setuptools/issues/851", - ) def test_mixed_site_and_non_site(self, tmpdir): """ Installing two packages sharing the same namespace, one installed -- cgit v1.2.1 From d3215c10b6f9ccd8940f9345642ee0718f158585 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Sat, 27 Oct 2018 11:25:51 +0100 Subject: Mark Py 2/3-only tests as skip instead of xfail Also reuse pre-defined py2_only and py3_only decorators where appropriate. --- setuptools/tests/test_namespaces.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index da19bd79..670ccee9 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -12,7 +12,7 @@ from setuptools.command import test class TestNamespaces: - @pytest.mark.xfail( + @pytest.mark.skipif( sys.version_info < (3, 5), reason="Requires importlib.util.module_from_spec", ) -- cgit v1.2.1 From 5cd86987530892bfb01f68ad5f1a2b997a3d01e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 26 Jan 2019 20:20:12 -0500 Subject: Feed the hobgoblins (delint). --- setuptools/tests/test_namespaces.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 670ccee9..f937d981 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -1,6 +1,5 @@ from __future__ import absolute_import, unicode_literals -import os import sys import subprocess -- cgit v1.2.1 From 6e1838a9fb5feb000ba9b6a3c37c8b39d7e872b3 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Thu, 14 Nov 2019 21:51:33 +0100 Subject: drop easy_install script and associated documentation --- setuptools/tests/test_namespaces.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index f937d981..3c5df68a 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -64,9 +64,8 @@ class TestNamespaces: target.mkdir() install_cmd = [ sys.executable, - '-m', 'easy_install', - '-d', str(target), - str(pkg), + '-m', 'pip.__main__', 'install', + '-t', str(target), str(pkg), ] with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(install_cmd) -- cgit v1.2.1 From a1e956b20f11f2d02f5a9855bda37660080184c9 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 16 Nov 2019 23:30:10 +0100 Subject: Revert "drop easy_install script and associated documentation" This reverts commit 6e1838a9fb5feb000ba9b6a3c37c8b39d7e872b3. --- setuptools/tests/test_namespaces.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 3c5df68a..f937d981 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -64,8 +64,9 @@ class TestNamespaces: target.mkdir() install_cmd = [ sys.executable, - '-m', 'pip.__main__', 'install', - '-t', str(target), str(pkg), + '-m', 'easy_install', + '-d', str(target), + str(pkg), ] with test.test.paths_on_pythonpath([str(target)]): subprocess.check_call(install_cmd) -- cgit v1.2.1 From fb7ab81a3d080422687bad71f9ae9d36eeefbee2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Aug 2020 00:29:24 -0400 Subject: Remove Python 2 compatibility --- setuptools/tests/test_namespaces.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index f937d981..6c8c522d 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - import sys import subprocess -- cgit v1.2.1 From 4b0408a18dcda286af6668b7ef6934e53d1f247c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 20 Jan 2021 21:02:24 -0500 Subject: Remove easy_install script and module. --- setuptools/tests/test_namespaces.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/tests/test_namespaces.py') diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py index 6c8c522d..270f90c9 100644 --- a/setuptools/tests/test_namespaces.py +++ b/setuptools/tests/test_namespaces.py @@ -62,8 +62,9 @@ class TestNamespaces: target.mkdir() install_cmd = [ sys.executable, - '-m', 'easy_install', - '-d', str(target), + '-m', 'pip', + 'install', + '-t', str(target), str(pkg), ] with test.test.paths_on_pythonpath([str(target)]): -- cgit v1.2.1