aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_find_packages.py
diff options
context:
space:
mode:
authorWyatt Lee Baldwin <self@wyattbaldwin.com>2014-02-12 00:52:26 -0800
committerWyatt Lee Baldwin <self@wyattbaldwin.com>2014-02-12 00:52:26 -0800
commit80fc5b6d418b2df0243989b1b8c999f795f3f55e (patch)
treede140863069aff43238daab5ec746a530ce97ac5 /setuptools/tests/test_find_packages.py
parentc74177b8d8c565650abec45d2f90550be0c2702f (diff)
downloadexternal_python_setuptools-80fc5b6d418b2df0243989b1b8c999f795f3f55e.tar.gz
external_python_setuptools-80fc5b6d418b2df0243989b1b8c999f795f3f55e.tar.bz2
external_python_setuptools-80fc5b6d418b2df0243989b1b8c999f795f3f55e.zip
Add support for PEP 420 namespace packages to find_packages()
On Python 3.3+, `find_packages()` now considers any subdirectory of the start directory that's not a regular package (i.e., that doesn't have an `__init__.py`) to be a namespace package. The other way this supports PEP 420 is by making sure `__pycache__` directories are never added to the list of packages. Fixes issue #97
Diffstat (limited to 'setuptools/tests/test_find_packages.py')
-rw-r--r--setuptools/tests/test_find_packages.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/setuptools/tests/test_find_packages.py b/setuptools/tests/test_find_packages.py
index c50309d2..abb0dd61 100644
--- a/setuptools/tests/test_find_packages.py
+++ b/setuptools/tests/test_find_packages.py
@@ -1,12 +1,16 @@
"""Tests for setuptools.find_packages()."""
import os
import shutil
+import sys
import tempfile
import unittest
from setuptools import find_packages
+PEP420 = sys.version_info[:2] >= (3, 3)
+
+
class TestFindPackages(unittest.TestCase):
def setUp(self):
@@ -58,6 +62,7 @@ class TestFindPackages(unittest.TestCase):
fp.close()
return path
+ @unittest.skipIf(PEP420, 'Not a PEP 420 env')
def test_regular_package(self):
self._touch('__init__.py', self.pkg_dir)
packages = find_packages(self.dist_dir)
@@ -80,3 +85,36 @@ class TestFindPackages(unittest.TestCase):
self._touch('file.dat', data_dir)
packages = find_packages(self.dist_dir)
self.assertTrue('pkg.some.data' not in packages)
+
+ @unittest.skipIf(not PEP420, 'PEP 420 only')
+ def test_pep420_ns_package(self):
+ packages = find_packages(
+ self.dist_dir, include=['pkg*'], exclude=['pkg.subpkg.assets'])
+ self.assertEqual(packages, ['pkg', 'pkg.nspkg', 'pkg.subpkg'])
+
+ @unittest.skipIf(not PEP420, 'PEP 420 only')
+ def test_pep420_ns_package_no_includes(self):
+ packages = find_packages(
+ self.dist_dir, exclude=['pkg.subpkg.assets'])
+ self.assertEqual(packages, ['docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg'])
+
+ @unittest.skipIf(not PEP420, 'PEP 420 only')
+ def test_pep420_ns_package_no_includes_or_excludes(self):
+ packages = find_packages(self.dist_dir)
+ expected = [
+ 'docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg', 'pkg.subpkg.assets']
+ self.assertEqual(packages, expected)
+
+ @unittest.skipIf(not PEP420, 'PEP 420 only')
+ def test_regular_package_with_nested_pep420_ns_packages(self):
+ self._touch('__init__.py', self.pkg_dir)
+ packages = find_packages(
+ self.dist_dir, exclude=['docs', 'pkg.subpkg.assets'])
+ self.assertEqual(packages, ['pkg', 'pkg.nspkg', 'pkg.subpkg'])
+
+ @unittest.skipIf(not PEP420, 'PEP 420 only')
+ def test_pep420_ns_package_no_non_package_dirs(self):
+ shutil.rmtree(self.docs_dir)
+ shutil.rmtree(os.path.join(self.dist_dir, 'pkg/subpkg/assets'))
+ packages = find_packages(self.dist_dir)
+ self.assertEqual(packages, ['pkg', 'pkg.nspkg', 'pkg.subpkg'])