aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_resources.py
diff options
context:
space:
mode:
authorAurelien Bompard <aurelien@bompard.org>2011-05-17 08:12:10 +0200
committerAurelien Bompard <aurelien@bompard.org>2011-05-17 08:12:10 +0200
commit606015e88f41070ffb182dfcc57926a858dd3358 (patch)
tree632ac4b3320eb758a59066f6368f27485c6c80a0 /setuptools/tests/test_resources.py
parent44c1998e667e3ccd2f793e29c6bac3806a08e1ee (diff)
downloadexternal_python_setuptools-606015e88f41070ffb182dfcc57926a858dd3358.tar.gz
external_python_setuptools-606015e88f41070ffb182dfcc57926a858dd3358.tar.bz2
external_python_setuptools-606015e88f41070ffb182dfcc57926a858dd3358.zip
Don't try to import the parent of a namespace package in declare_namespace -- fixes #204
--HG-- branch : distribute extra : rebase_source : 1644e937b2d0b2fae58e27740d0fddfe082586cd
Diffstat (limited to 'setuptools/tests/test_resources.py')
-rw-r--r--setuptools/tests/test_resources.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 883cfad1..e02bd8d5 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -3,7 +3,7 @@
# NOTE: the shebang and encoding lines are for ScriptHeaderTests; do not remove
from unittest import TestCase, makeSuite; from pkg_resources import *
from setuptools.command.easy_install import get_script_header, is_sh
-import os, pkg_resources, sys, StringIO
+import os, pkg_resources, sys, StringIO, tempfile, shutil
try: frozenset
except NameError:
from sets import ImmutableSet as frozenset
@@ -563,3 +563,29 @@ class ScriptHeaderTests(TestCase):
sys.platform = platform
sys.stdout = stdout
+
+
+
+class NamespaceTests(TestCase):
+
+ def setUp(self):
+ self._ns_pkgs = pkg_resources._namespace_packages.copy()
+ self._tmpdir = tempfile.mkdtemp(prefix="tests-distribute-")
+ sys.path.append(self._tmpdir)
+
+ def tearDown(self):
+ shutil.rmtree(self._tmpdir)
+ pkg_resources._namespace_packages = self._ns_pkgs.copy()
+ sys.path.remove(self._tmpdir)
+
+ def test_two_levels_deep(self):
+ os.makedirs(os.path.join(self._tmpdir, "pkg1", "pkg2"))
+ declare_namespace("pkg1")
+ self.assertTrue("pkg1" in pkg_resources._namespace_packages.keys())
+ try:
+ declare_namespace("pkg1.pkg2")
+ except ImportError, e:
+ self.fail("Distribute tried to import the parent namespace package")
+ self.assertTrue("pkg1.pkg2" in pkg_resources._namespace_packages.keys())
+ self.assertEqual(pkg_resources._namespace_packages["pkg1"], ["pkg1.pkg2"])
+