aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-12-11 15:20:32 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-12-11 15:32:28 -0500
commit3dd506f01d48b98aeea9bdbca0105d4c7d8ad538 (patch)
tree07b3933bd8651b7ac184736f2a3463a483e4e7b5 /setuptools/tests
parent2268fb9887cfea2e28e156bd2c8314132261402f (diff)
parent5c9406987aacf17d9c004aa1456797e0044306e5 (diff)
downloadexternal_python_setuptools-develop-nspkg-always.tar.gz
external_python_setuptools-develop-nspkg-always.tar.bz2
external_python_setuptools-develop-nspkg-always.zip
Merge branch 'master' into develop-nspkg-alwaysdevelop-nspkg-always
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/environment.py2
-rw-r--r--setuptools/tests/namespaces.py42
-rw-r--r--setuptools/tests/test_config.py539
-rw-r--r--setuptools/tests/test_develop.py46
-rw-r--r--setuptools/tests/test_egg_info.py11
-rw-r--r--setuptools/tests/test_manifest.py12
-rw-r--r--setuptools/tests/test_namespaces.py52
-rw-r--r--setuptools/tests/test_sandbox.py16
-rw-r--r--setuptools/tests/test_sdist.py9
9 files changed, 667 insertions, 62 deletions
diff --git a/setuptools/tests/environment.py b/setuptools/tests/environment.py
index b0e3bd36..c67898ca 100644
--- a/setuptools/tests/environment.py
+++ b/setuptools/tests/environment.py
@@ -56,5 +56,5 @@ def run_setup_py(cmd, pypath=None, path=None,
data = data.decode()
data = unicodedata.normalize('NFC', data)
- # communciate calls wait()
+ # communicate calls wait()
return proc.returncode, data
diff --git a/setuptools/tests/namespaces.py b/setuptools/tests/namespaces.py
new file mode 100644
index 00000000..ef5ecdad
--- /dev/null
+++ b/setuptools/tests/namespaces.py
@@ -0,0 +1,42 @@
+from __future__ import absolute_import, unicode_literals
+
+import textwrap
+
+
+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
+
+
+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')
diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py
new file mode 100644
index 00000000..fa8d523b
--- /dev/null
+++ b/setuptools/tests/test_config.py
@@ -0,0 +1,539 @@
+import contextlib
+import pytest
+from distutils.errors import DistutilsOptionError, DistutilsFileError
+from setuptools.dist import Distribution
+from setuptools.config import ConfigHandler, read_configuration
+
+
+class ErrConfigHandler(ConfigHandler):
+ """Erroneous handler. Fails to implement required methods."""
+
+
+def make_package_dir(name, base_dir):
+ dir_package = base_dir.mkdir(name)
+ init_file = dir_package.join('__init__.py')
+ init_file.write('')
+ return dir_package, init_file
+
+
+def fake_env(tmpdir, setup_cfg, setup_py=None):
+
+ if setup_py is None:
+ setup_py = (
+ 'from setuptools import setup\n'
+ 'setup()\n'
+ )
+
+ tmpdir.join('setup.py').write(setup_py)
+ config = tmpdir.join('setup.cfg')
+ config.write(setup_cfg)
+
+ package_dir, init_file = make_package_dir('fake_package', tmpdir)
+
+ init_file.write(
+ 'VERSION = (1, 2, 3)\n'
+ '\n'
+ 'VERSION_MAJOR = 1'
+ '\n'
+ 'def get_version():\n'
+ ' return [3, 4, 5, "dev"]\n'
+ '\n'
+ )
+ return package_dir, config
+
+
+@contextlib.contextmanager
+def get_dist(tmpdir, kwargs_initial=None, parse=True):
+ kwargs_initial = kwargs_initial or {}
+
+ with tmpdir.as_cwd():
+ dist = Distribution(kwargs_initial)
+ dist.script_name = 'setup.py'
+ parse and dist.parse_config_files()
+
+ yield dist
+
+
+def test_parsers_implemented():
+
+ with pytest.raises(NotImplementedError):
+ handler = ErrConfigHandler(None, {})
+ handler.parsers
+
+
+class TestConfigurationReader:
+
+ def test_basic(self, tmpdir):
+ _, config = fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'version = 10.1.1\n'
+ 'keywords = one, two\n'
+ '\n'
+ '[options]\n'
+ 'scripts = bin/a.py, bin/b.py\n'
+ )
+ config_dict = read_configuration('%s' % config)
+ assert config_dict['metadata']['version'] == '10.1.1'
+ assert config_dict['metadata']['keywords'] == ['one', 'two']
+ assert config_dict['options']['scripts'] == ['bin/a.py', 'bin/b.py']
+
+ def test_no_config(self, tmpdir):
+ with pytest.raises(DistutilsFileError):
+ read_configuration('%s' % tmpdir.join('setup.cfg'))
+
+ def test_ignore_errors(self, tmpdir):
+ _, config = fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'version = attr: none.VERSION\n'
+ 'keywords = one, two\n'
+ )
+ with pytest.raises(ImportError):
+ read_configuration('%s' % config)
+
+ config_dict = read_configuration(
+ '%s' % config, ignore_option_errors=True)
+
+ assert config_dict['metadata']['keywords'] == ['one', 'two']
+ assert 'version' not in config_dict['metadata']
+
+ config.remove()
+
+
+class TestMetadata:
+
+ def test_basic(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'version = 10.1.1\n'
+ 'description = Some description\n'
+ 'long_description = file: README\n'
+ 'name = fake_name\n'
+ 'keywords = one, two\n'
+ 'provides = package, package.sub\n'
+ 'license = otherlic\n'
+ 'download_url = http://test.test.com/test/\n'
+ 'maintainer_email = test@test.com\n'
+ )
+
+ tmpdir.join('README').write('readme contents\nline2')
+
+ meta_initial = {
+ # This will be used so `otherlic` won't replace it.
+ 'license': 'BSD 3-Clause License',
+ }
+
+ with get_dist(tmpdir, meta_initial) as dist:
+ metadata = dist.metadata
+
+ assert metadata.version == '10.1.1'
+ assert metadata.description == 'Some description'
+ assert metadata.long_description == 'readme contents\nline2'
+ assert metadata.provides == ['package', 'package.sub']
+ assert metadata.license == 'BSD 3-Clause License'
+ assert metadata.name == 'fake_name'
+ assert metadata.keywords == ['one', 'two']
+ assert metadata.download_url == 'http://test.test.com/test/'
+ assert metadata.maintainer_email == 'test@test.com'
+
+ def test_file_sandboxed(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'long_description = file: ../../README\n'
+ )
+
+ with get_dist(tmpdir, parse=False) as dist:
+ with pytest.raises(DistutilsOptionError):
+ dist.parse_config_files() # file: out of sandbox
+
+ def test_aliases(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'author-email = test@test.com\n'
+ 'home-page = http://test.test.com/test/\n'
+ 'summary = Short summary\n'
+ 'platform = a, b\n'
+ 'classifier =\n'
+ ' Framework :: Django\n'
+ ' Programming Language :: Python :: 3.5\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ metadata = dist.metadata
+ assert metadata.author_email == 'test@test.com'
+ assert metadata.url == 'http://test.test.com/test/'
+ assert metadata.description == 'Short summary'
+ assert metadata.platforms == ['a', 'b']
+ assert metadata.classifiers == [
+ 'Framework :: Django',
+ 'Programming Language :: Python :: 3.5',
+ ]
+
+ def test_multiline(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'name = fake_name\n'
+ 'keywords =\n'
+ ' one\n'
+ ' two\n'
+ 'classifiers =\n'
+ ' Framework :: Django\n'
+ ' Programming Language :: Python :: 3.5\n'
+ )
+ with get_dist(tmpdir) as dist:
+ metadata = dist.metadata
+ assert metadata.keywords == ['one', 'two']
+ assert metadata.classifiers == [
+ 'Framework :: Django',
+ 'Programming Language :: Python :: 3.5',
+ ]
+
+ def test_version(self, tmpdir):
+
+ _, config = fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'version = attr: fake_package.VERSION\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.metadata.version == '1.2.3'
+
+ config.write(
+ '[metadata]\n'
+ 'version = attr: fake_package.get_version\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.metadata.version == '3.4.5.dev'
+
+ config.write(
+ '[metadata]\n'
+ 'version = attr: fake_package.VERSION_MAJOR\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.metadata.version == '1'
+
+ subpack = tmpdir.join('fake_package').mkdir('subpackage')
+ subpack.join('__init__.py').write('')
+ subpack.join('submodule.py').write('VERSION = (2016, 11, 26)')
+
+ config.write(
+ '[metadata]\n'
+ 'version = attr: fake_package.subpackage.submodule.VERSION\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.metadata.version == '2016.11.26'
+
+ def test_unknown_meta_item(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'name = fake_name\n'
+ 'unknown = some\n'
+ )
+ with get_dist(tmpdir, parse=False) as dist:
+ dist.parse_config_files() # Skip unknown.
+
+ def test_usupported_section(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[metadata.some]\n'
+ 'key = val\n'
+ )
+ with get_dist(tmpdir, parse=False) as dist:
+ with pytest.raises(DistutilsOptionError):
+ dist.parse_config_files()
+
+ def test_classifiers(self, tmpdir):
+ expected = set([
+ 'Framework :: Django',
+ 'Programming Language :: Python :: 3.5',
+ ])
+
+ # From file.
+ _, config = fake_env(
+ tmpdir,
+ '[metadata]\n'
+ 'classifiers = file: classifiers\n'
+ )
+
+ tmpdir.join('classifiers').write(
+ 'Framework :: Django\n'
+ 'Programming Language :: Python :: 3.5\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert set(dist.metadata.classifiers) == expected
+
+ # From section.
+ config.write(
+ '[metadata.classifiers]\n'
+ 'Framework :: Django\n'
+ 'Programming Language :: Python :: 3.5\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert set(dist.metadata.classifiers) == expected
+
+
+class TestOptions:
+
+ def test_basic(self, tmpdir):
+
+ fake_env(
+ tmpdir,
+ '[options]\n'
+ 'zip_safe = True\n'
+ 'use_2to3 = 1\n'
+ 'include_package_data = yes\n'
+ 'package_dir = b=c, =src\n'
+ 'packages = pack_a, pack_b.subpack\n'
+ 'namespace_packages = pack1, pack2\n'
+ 'use_2to3_fixers = your.fixers, or.here\n'
+ 'use_2to3_exclude_fixers = one.here, two.there\n'
+ 'convert_2to3_doctests = src/tests/one.txt, src/two.txt\n'
+ 'scripts = bin/one.py, bin/two.py\n'
+ 'eager_resources = bin/one.py, bin/two.py\n'
+ 'install_requires = docutils>=0.3; pack ==1.1, ==1.3; hey\n'
+ 'tests_require = mock==0.7.2; pytest\n'
+ 'setup_requires = docutils>=0.3; spack ==1.1, ==1.3; there\n'
+ 'dependency_links = http://some.com/here/1, '
+ 'http://some.com/there/2\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.zip_safe
+ assert dist.use_2to3
+ assert dist.include_package_data
+ assert dist.package_dir == {'': 'src', 'b': 'c'}
+ assert dist.packages == ['pack_a', 'pack_b.subpack']
+ assert dist.namespace_packages == ['pack1', 'pack2']
+ assert dist.use_2to3_fixers == ['your.fixers', 'or.here']
+ assert dist.use_2to3_exclude_fixers == ['one.here', 'two.there']
+ assert dist.convert_2to3_doctests == ([
+ 'src/tests/one.txt', 'src/two.txt'])
+ assert dist.scripts == ['bin/one.py', 'bin/two.py']
+ assert dist.dependency_links == ([
+ 'http://some.com/here/1',
+ 'http://some.com/there/2'
+ ])
+ assert dist.install_requires == ([
+ 'docutils>=0.3',
+ 'pack ==1.1, ==1.3',
+ 'hey'
+ ])
+ assert dist.setup_requires == ([
+ 'docutils>=0.3',
+ 'spack ==1.1, ==1.3',
+ 'there'
+ ])
+ assert dist.tests_require == ['mock==0.7.2', 'pytest']
+
+ def test_multiline(self, tmpdir):
+ fake_env(
+ tmpdir,
+ '[options]\n'
+ 'package_dir = \n'
+ ' b=c\n'
+ ' =src\n'
+ 'packages = \n'
+ ' pack_a\n'
+ ' pack_b.subpack\n'
+ 'namespace_packages = \n'
+ ' pack1\n'
+ ' pack2\n'
+ 'use_2to3_fixers = \n'
+ ' your.fixers\n'
+ ' or.here\n'
+ 'use_2to3_exclude_fixers = \n'
+ ' one.here\n'
+ ' two.there\n'
+ 'convert_2to3_doctests = \n'
+ ' src/tests/one.txt\n'
+ ' src/two.txt\n'
+ 'scripts = \n'
+ ' bin/one.py\n'
+ ' bin/two.py\n'
+ 'eager_resources = \n'
+ ' bin/one.py\n'
+ ' bin/two.py\n'
+ 'install_requires = \n'
+ ' docutils>=0.3\n'
+ ' pack ==1.1, ==1.3\n'
+ ' hey\n'
+ 'tests_require = \n'
+ ' mock==0.7.2\n'
+ ' pytest\n'
+ 'setup_requires = \n'
+ ' docutils>=0.3\n'
+ ' spack ==1.1, ==1.3\n'
+ ' there\n'
+ 'dependency_links = \n'
+ ' http://some.com/here/1\n'
+ ' http://some.com/there/2\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert dist.package_dir == {'': 'src', 'b': 'c'}
+ assert dist.packages == ['pack_a', 'pack_b.subpack']
+ assert dist.namespace_packages == ['pack1', 'pack2']
+ assert dist.use_2to3_fixers == ['your.fixers', 'or.here']
+ assert dist.use_2to3_exclude_fixers == ['one.here', 'two.there']
+ assert dist.convert_2to3_doctests == (
+ ['src/tests/one.txt', 'src/two.txt'])
+ assert dist.scripts == ['bin/one.py', 'bin/two.py']
+ assert dist.dependency_links == ([
+ 'http://some.com/here/1',
+ 'http://some.com/there/2'
+ ])
+ assert dist.install_requires == ([
+ 'docutils>=0.3',
+ 'pack ==1.1, ==1.3',
+ 'hey'
+ ])
+ assert dist.setup_requires == ([
+ 'docutils>=0.3',
+ 'spack ==1.1, ==1.3',
+ 'there'
+ ])
+ assert dist.tests_require == ['mock==0.7.2', 'pytest']
+
+ def test_package_dir_fail(self, tmpdir):
+ fake_env(
+ tmpdir,
+ '[options]\n'
+ 'package_dir = a b\n'
+ )
+ with get_dist(tmpdir, parse=False) as dist:
+ with pytest.raises(DistutilsOptionError):
+ dist.parse_config_files()
+
+ def test_package_data(self, tmpdir):
+ fake_env(
+ tmpdir,
+ '[options.package_data]\n'
+ '* = *.txt, *.rst\n'
+ 'hello = *.msg\n'
+ '\n'
+ '[options.exclude_package_data]\n'
+ '* = fake1.txt, fake2.txt\n'
+ 'hello = *.dat\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert dist.package_data == {
+ '': ['*.txt', '*.rst'],
+ 'hello': ['*.msg'],
+ }
+ assert dist.exclude_package_data == {
+ '': ['fake1.txt', 'fake2.txt'],
+ 'hello': ['*.dat'],
+ }
+
+ def test_packages(self, tmpdir):
+ fake_env(
+ tmpdir,
+ '[options]\n'
+ 'packages = find:\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert dist.packages == ['fake_package']
+
+ def test_find_directive(self, tmpdir):
+ dir_package, config = fake_env(
+ tmpdir,
+ '[options]\n'
+ 'packages = find:\n'
+ )
+
+ dir_sub_one, _ = make_package_dir('sub_one', dir_package)
+ dir_sub_two, _ = make_package_dir('sub_two', dir_package)
+
+ with get_dist(tmpdir) as dist:
+ assert set(dist.packages) == set([
+ 'fake_package', 'fake_package.sub_two', 'fake_package.sub_one'
+ ])
+
+ config.write(
+ '[options]\n'
+ 'packages = find:\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:\n'
+ '\n'
+ '[options.packages.find]\n'
+ 'exclude =\n'
+ ' fake_package.sub_one\n'
+ )
+ with get_dist(tmpdir) as dist:
+ assert set(dist.packages) == set(
+ ['fake_package', 'fake_package.sub_two'])
+
+ def test_extras_require(self, tmpdir):
+ fake_env(
+ tmpdir,
+ '[options.extras_require]\n'
+ 'pdf = ReportLab>=1.2; RXP\n'
+ 'rest = \n'
+ ' docutils>=0.3\n'
+ ' pack ==1.1, ==1.3\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert dist.extras_require == {
+ 'pdf': ['ReportLab>=1.2', 'RXP'],
+ 'rest': ['docutils>=0.3', 'pack ==1.1, ==1.3']
+ }
+
+ def test_entry_points(self, tmpdir):
+ _, config = fake_env(
+ tmpdir,
+ '[options.entry_points]\n'
+ 'group1 = point1 = pack.module:func, '
+ '.point2 = pack.module2:func_rest [rest]\n'
+ 'group2 = point3 = pack.module:func2\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert dist.entry_points == {
+ 'group1': [
+ 'point1 = pack.module:func',
+ '.point2 = pack.module2:func_rest [rest]',
+ ],
+ 'group2': ['point3 = pack.module:func2']
+ }
+
+ expected = (
+ '[blogtool.parsers]\n'
+ '.rst = some.nested.module:SomeClass.some_classmethod[reST]\n'
+ )
+
+ tmpdir.join('entry_points').write(expected)
+
+ # From file.
+ config.write(
+ '[options]\n'
+ 'entry_points = file: entry_points\n'
+ )
+
+ with get_dist(tmpdir) as dist:
+ assert dist.entry_points == expected
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py
index fb8e0e3f..e0227453 100644
--- a/setuptools/tests/test_develop.py
+++ b/setuptools/tests/test_develop.py
@@ -7,7 +7,6 @@ import os
import site
import sys
import io
-import textwrap
import subprocess
from setuptools.extern import six
@@ -17,6 +16,7 @@ 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
@@ -122,44 +122,6 @@ class TestDevelop:
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')
@staticmethod
def install_develop(src_dir, target):
@@ -181,8 +143,8 @@ class TestNamespaces:
and the other installed using `develop` 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')
target = tmpdir / 'packages'
# use pip to install to the target directory
install_cmd = [
@@ -193,7 +155,7 @@ class TestNamespaces:
]
subprocess.check_call(install_cmd)
self.install_develop(pkg_B, target)
- self.make_site_dir(target)
+ namespaces.make_site_dir(target)
try_import = [
sys.executable,
'-c', 'import myns.pkgA; import myns.pkgB',
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index 12c10497..75ae18df 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -4,7 +4,7 @@ import re
import stat
import sys
-from setuptools.command.egg_info import egg_info
+from setuptools.command.egg_info import egg_info, manifest_maker
from setuptools.dist import Distribution
from setuptools.extern.six.moves import map
@@ -237,6 +237,15 @@ class TestEggInfo(object):
pkginfo = os.path.join(egg_info_dir, 'PKG-INFO')
assert 'Requires-Python: >=1.2.3' in open(pkginfo).read().split('\n')
+ def test_manifest_maker_warning_suppression(self):
+ fixtures = [
+ "standard file not found: should have one of foo.py, bar.py",
+ "standard file 'setup.py' not found"
+ ]
+
+ for msg in fixtures:
+ assert manifest_maker._should_suppress_warning(msg)
+
def _run_install_command(self, tmpdir_cwd, env, cmd=None, output=None):
environ = os.environ.copy().update(
HOME=env.paths['home'],
diff --git a/setuptools/tests/test_manifest.py b/setuptools/tests/test_manifest.py
index 602c43a2..62b6d708 100644
--- a/setuptools/tests/test_manifest.py
+++ b/setuptools/tests/test_manifest.py
@@ -449,6 +449,11 @@ class TestFileListTest(TempDirTestCase):
assert file_list.files == ['a.py', l('d/c.py')]
self.assertWarnings()
+ file_list.process_template_line('global-include .txt')
+ file_list.sort()
+ assert file_list.files == ['a.py', 'b.txt', l('d/c.py')]
+ self.assertNoWarnings()
+
def test_global_exclude(self):
l = make_local_path
# global-exclude
@@ -465,6 +470,13 @@ class TestFileListTest(TempDirTestCase):
assert file_list.files == ['b.txt']
self.assertWarnings()
+ file_list = FileList()
+ file_list.files = ['a.py', 'b.txt', l('d/c.pyc'), 'e.pyo']
+ file_list.process_template_line('global-exclude .py[co]')
+ file_list.sort()
+ assert file_list.files == ['a.py', 'b.txt']
+ self.assertNoWarnings()
+
def test_recursive_include(self):
l = make_local_path
# recursive-include
diff --git a/setuptools/tests/test_namespaces.py b/setuptools/tests/test_namespaces.py
new file mode 100644
index 00000000..28c5e9de
--- /dev/null
+++ b/setuptools/tests/test_namespaces.py
@@ -0,0 +1,52 @@
+from __future__ import absolute_import, unicode_literals
+
+import os
+import sys
+import subprocess
+
+import pytest
+
+from . import namespaces
+
+
+class TestNamespaces:
+
+ @pytest.mark.xfail(sys.version_info < (3, 3),
+ reason="Requires PEP 420")
+ @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):
+ """
+ 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 = 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
+ 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)
+ namespaces.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)
diff --git a/setuptools/tests/test_sandbox.py b/setuptools/tests/test_sandbox.py
index b92a477a..929f0a5b 100644
--- a/setuptools/tests/test_sandbox.py
+++ b/setuptools/tests/test_sandbox.py
@@ -23,22 +23,6 @@ class TestSandbox:
return do_write
- def test_win32com(self, tmpdir):
- """
- win32com should not be prevented from caching COM interfaces
- in gen_py.
- """
- win32com = pytest.importorskip('win32com')
- gen_py = win32com.__gen_path__
- target = os.path.join(gen_py, 'test_write')
- sandbox = DirectorySandbox(str(tmpdir))
- try:
- # attempt to create gen_py file
- sandbox.run(self._file_writer(target))
- finally:
- if os.path.exists(target):
- os.remove(target)
-
def test_setup_py_with_BOM(self):
"""
It should be possible to execute a setup.py with a Byte Order Mark
diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py
index 609c7830..f34068dc 100644
--- a/setuptools/tests/test_sdist.py
+++ b/setuptools/tests/test_sdist.py
@@ -26,7 +26,8 @@ SETUP_ATTRS = {
'name': 'sdist_test',
'version': '0.0',
'packages': ['sdist_test'],
- 'package_data': {'sdist_test': ['*.txt']}
+ 'package_data': {'sdist_test': ['*.txt']},
+ 'data_files': [("data", [os.path.join("d", "e.dat")])],
}
SETUP_PY = """\
@@ -95,9 +96,12 @@ class TestSdistTest:
# Set up the rest of the test package
test_pkg = os.path.join(self.temp_dir, 'sdist_test')
os.mkdir(test_pkg)
+ data_folder = os.path.join(self.temp_dir, "d")
+ os.mkdir(data_folder)
# *.rst was not included in package_data, so c.rst should not be
# automatically added to the manifest when not under version control
- for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst']:
+ for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst',
+ os.path.join(data_folder, "e.dat")]:
# Just touch the files; their contents are irrelevant
open(os.path.join(test_pkg, fname), 'w').close()
@@ -126,6 +130,7 @@ class TestSdistTest:
assert os.path.join('sdist_test', 'a.txt') in manifest
assert os.path.join('sdist_test', 'b.txt') in manifest
assert os.path.join('sdist_test', 'c.rst') not in manifest
+ assert os.path.join('d', 'e.dat') in manifest
def test_defaults_case_sensitivity(self):
"""