aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_config.py
diff options
context:
space:
mode:
authorCarsten Klein <trancesilken@gmail.com>2018-08-17 14:58:35 +0200
committerPaul Ganssle <pganssle@users.noreply.github.com>2018-08-17 08:58:35 -0400
commit0254a2fda8e8bd4f289d01e2179191e936517f04 (patch)
tree6007c5bc0b659c4d69ffbcc8df917f7a0c747cdf /setuptools/tests/test_config.py
parentbbf99b7e599766e15dc56f58f68fe6c32c972faf (diff)
downloadexternal_python_setuptools-0254a2fda8e8bd4f289d01e2179191e936517f04.tar.gz
external_python_setuptools-0254a2fda8e8bd4f289d01e2179191e936517f04.tar.bz2
external_python_setuptools-0254a2fda8e8bd4f289d01e2179191e936517f04.zip
Rename find_namepaces_ns to find_namespace_packages (#1423)
* fix #1419 PEP420: add find_namespace: directive * fix #1419 PEP420: add find_namespace: directive to documentation * fix #1419 PEP420: add tests * fix #1419 PEP420: clean up code * fix #1419 PEP420: fix typo in documentation * fix #1419 PEP420: fix typo in documentation * fix #1419 PEP420: clean up code * fix #1419 PEP420: add changelog entry * fixup! fix #1419 PEP420: add tests * fix #1419 PEP420: cleanup code refactor markers * #1420: Rename find_namespace_ns to find_namespace_packages * #1420: update changelog entry
Diffstat (limited to 'setuptools/tests/test_config.py')
-rw-r--r--setuptools/tests/test_config.py64
1 files changed, 60 insertions, 4 deletions
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
index 19b37633..acf22154 100644
--- a/setuptools/tests/test_config.py
+++ b/setuptools/tests/test_config.py
@@ -4,18 +4,20 @@ from distutils.errors import DistutilsOptionError, DistutilsFileError
from mock import patch
from setuptools.dist import Distribution, _Distribution
from setuptools.config import ConfigHandler, read_configuration
-
+from . import py2_only, py3_only
class ErrConfigHandler(ConfigHandler):
"""Erroneous handler. Fails to implement required methods."""
-def make_package_dir(name, base_dir):
+def make_package_dir(name, base_dir, ns=False):
dir_package = base_dir
for dir_name in name.split('/'):
dir_package = dir_package.mkdir(dir_name)
- init_file = dir_package.join('__init__.py')
- init_file.write('')
+ init_file = None
+ if not ns:
+ init_file = dir_package.join('__init__.py')
+ init_file.write('')
return dir_package, init_file
@@ -596,6 +598,60 @@ class TestOptions:
assert set(dist.packages) == set(
['fake_package', 'fake_package.sub_two'])
+ @py2_only
+ def test_find_namespace_directive_fails_on_py2(self, tmpdir):
+ dir_package, config = fake_env(
+ tmpdir,
+ '[options]\n'
+ 'packages = find_namespace:\n'
+ )
+
+ with pytest.raises(DistutilsOptionError):
+ with get_dist(tmpdir) as dist:
+ dist.parse_config_files()
+
+ @py3_only
+ def test_find_namespace_directive(self, tmpdir):
+ dir_package, config = fake_env(
+ tmpdir,
+ '[options]\n'
+ 'packages = find_namespace:\n'
+ )
+
+ dir_sub_one, _ = make_package_dir('sub_one', dir_package)
+ dir_sub_two, _ = make_package_dir('sub_two', dir_package, ns=True)
+
+ with get_dist(tmpdir) as dist:
+ assert set(dist.packages) == {
+ 'fake_package', 'fake_package.sub_two', 'fake_package.sub_one'
+ }
+
+ config.write(
+ '[options]\n'
+ 'packages = find_namespace:\n'
+ '\n'
+ '[options.packages.find]\n'
+ 'where = .\n'
+ 'include =\n'
+ ' fake_package.sub_one\n'
+ ' two\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.packages == ['fake_package.sub_one']
+
+ config.write(
+ '[options]\n'
+ 'packages = find_namespace:\n'
+ '\n'
+ '[options.packages.find]\n'
+ 'exclude =\n'
+ ' fake_package.sub_one\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert set(dist.packages) == {
+ 'fake_package', 'fake_package.sub_two'
+ }
+
def test_extras_require(self, tmpdir):
fake_env(
tmpdir,