summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-05-07 16:13:33 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2016-05-09 17:38:41 +0300
commit197fca8656e0a970066aea54072bc5dfc553adf4 (patch)
treee23758fc4e747d7823755568fbdd54ebc159272a
parent62bd3729ad95c7cd7b78b1e9c7bd1ac0f7ae9906 (diff)
downloadastroid-git-197fca8656e0a970066aea54072bc5dfc553adf4.tar.gz
Add test for old namespace packages protocol.
-rw-r--r--astroid/tests/testdata/python2/data/path_pkg_resources_1/package/__init__.py1
-rw-r--r--astroid/tests/testdata/python2/data/path_pkg_resources_1/package/foo.py0
-rw-r--r--astroid/tests/testdata/python2/data/path_pkg_resources_2/package/__init__.py1
-rw-r--r--astroid/tests/testdata/python2/data/path_pkg_resources_2/package/bar.py0
-rw-r--r--astroid/tests/testdata/python2/data/path_pkg_resources_3/package/__init__.py1
-rw-r--r--astroid/tests/testdata/python2/data/path_pkg_resources_3/package/baz.py0
-rw-r--r--astroid/tests/testdata/python2/data/path_pkgutil_1/package/__init__.py2
-rw-r--r--astroid/tests/testdata/python2/data/path_pkgutil_1/package/foo.py0
-rw-r--r--astroid/tests/testdata/python2/data/path_pkgutil_2/package/__init__.py2
-rw-r--r--astroid/tests/testdata/python2/data/path_pkgutil_2/package/bar.py0
-rw-r--r--astroid/tests/testdata/python2/data/path_pkgutil_3/package/__init__.py2
-rw-r--r--astroid/tests/testdata/python2/data/path_pkgutil_3/package/baz.py0
-rw-r--r--astroid/tests/testdata/python3/data/path_pkg_resources_1/package/__init__.py1
-rw-r--r--astroid/tests/testdata/python3/data/path_pkg_resources_1/package/foo.py0
-rw-r--r--astroid/tests/testdata/python3/data/path_pkg_resources_2/package/__init__.py1
-rw-r--r--astroid/tests/testdata/python3/data/path_pkg_resources_2/package/bar.py0
-rw-r--r--astroid/tests/testdata/python3/data/path_pkg_resources_3/package/__init__.py1
-rw-r--r--astroid/tests/testdata/python3/data/path_pkg_resources_3/package/baz.py0
-rw-r--r--astroid/tests/testdata/python3/data/path_pkgutil_1/package/__init__.py2
-rw-r--r--astroid/tests/testdata/python3/data/path_pkgutil_1/package/foo.py0
-rw-r--r--astroid/tests/testdata/python3/data/path_pkgutil_2/package/__init__.py2
-rw-r--r--astroid/tests/testdata/python3/data/path_pkgutil_2/package/bar.py0
-rw-r--r--astroid/tests/testdata/python3/data/path_pkgutil_3/package/__init__.py2
-rw-r--r--astroid/tests/testdata/python3/data/path_pkgutil_3/package/baz.py0
-rw-r--r--astroid/tests/unittest_manager.py19
25 files changed, 37 insertions, 0 deletions
diff --git a/astroid/tests/testdata/python2/data/path_pkg_resources_1/package/__init__.py b/astroid/tests/testdata/python2/data/path_pkg_resources_1/package/__init__.py
new file mode 100644
index 00000000..b0d64337
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkg_resources_1/package/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python2/data/path_pkg_resources_1/package/foo.py b/astroid/tests/testdata/python2/data/path_pkg_resources_1/package/foo.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkg_resources_1/package/foo.py
diff --git a/astroid/tests/testdata/python2/data/path_pkg_resources_2/package/__init__.py b/astroid/tests/testdata/python2/data/path_pkg_resources_2/package/__init__.py
new file mode 100644
index 00000000..b0d64337
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkg_resources_2/package/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python2/data/path_pkg_resources_2/package/bar.py b/astroid/tests/testdata/python2/data/path_pkg_resources_2/package/bar.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkg_resources_2/package/bar.py
diff --git a/astroid/tests/testdata/python2/data/path_pkg_resources_3/package/__init__.py b/astroid/tests/testdata/python2/data/path_pkg_resources_3/package/__init__.py
new file mode 100644
index 00000000..b0d64337
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkg_resources_3/package/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python2/data/path_pkg_resources_3/package/baz.py b/astroid/tests/testdata/python2/data/path_pkg_resources_3/package/baz.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkg_resources_3/package/baz.py
diff --git a/astroid/tests/testdata/python2/data/path_pkgutil_1/package/__init__.py b/astroid/tests/testdata/python2/data/path_pkgutil_1/package/__init__.py
new file mode 100644
index 00000000..0bfb5a62
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkgutil_1/package/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python2/data/path_pkgutil_1/package/foo.py b/astroid/tests/testdata/python2/data/path_pkgutil_1/package/foo.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkgutil_1/package/foo.py
diff --git a/astroid/tests/testdata/python2/data/path_pkgutil_2/package/__init__.py b/astroid/tests/testdata/python2/data/path_pkgutil_2/package/__init__.py
new file mode 100644
index 00000000..0bfb5a62
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkgutil_2/package/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python2/data/path_pkgutil_2/package/bar.py b/astroid/tests/testdata/python2/data/path_pkgutil_2/package/bar.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkgutil_2/package/bar.py
diff --git a/astroid/tests/testdata/python2/data/path_pkgutil_3/package/__init__.py b/astroid/tests/testdata/python2/data/path_pkgutil_3/package/__init__.py
new file mode 100644
index 00000000..0bfb5a62
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkgutil_3/package/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python2/data/path_pkgutil_3/package/baz.py b/astroid/tests/testdata/python2/data/path_pkgutil_3/package/baz.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python2/data/path_pkgutil_3/package/baz.py
diff --git a/astroid/tests/testdata/python3/data/path_pkg_resources_1/package/__init__.py b/astroid/tests/testdata/python3/data/path_pkg_resources_1/package/__init__.py
new file mode 100644
index 00000000..b0d64337
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkg_resources_1/package/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python3/data/path_pkg_resources_1/package/foo.py b/astroid/tests/testdata/python3/data/path_pkg_resources_1/package/foo.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkg_resources_1/package/foo.py
diff --git a/astroid/tests/testdata/python3/data/path_pkg_resources_2/package/__init__.py b/astroid/tests/testdata/python3/data/path_pkg_resources_2/package/__init__.py
new file mode 100644
index 00000000..b0d64337
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkg_resources_2/package/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python3/data/path_pkg_resources_2/package/bar.py b/astroid/tests/testdata/python3/data/path_pkg_resources_2/package/bar.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkg_resources_2/package/bar.py
diff --git a/astroid/tests/testdata/python3/data/path_pkg_resources_3/package/__init__.py b/astroid/tests/testdata/python3/data/path_pkg_resources_3/package/__init__.py
new file mode 100644
index 00000000..b0d64337
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkg_resources_3/package/__init__.py
@@ -0,0 +1 @@
+__import__('pkg_resources').declare_namespace(__name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python3/data/path_pkg_resources_3/package/baz.py b/astroid/tests/testdata/python3/data/path_pkg_resources_3/package/baz.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkg_resources_3/package/baz.py
diff --git a/astroid/tests/testdata/python3/data/path_pkgutil_1/package/__init__.py b/astroid/tests/testdata/python3/data/path_pkgutil_1/package/__init__.py
new file mode 100644
index 00000000..0bfb5a62
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkgutil_1/package/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python3/data/path_pkgutil_1/package/foo.py b/astroid/tests/testdata/python3/data/path_pkgutil_1/package/foo.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkgutil_1/package/foo.py
diff --git a/astroid/tests/testdata/python3/data/path_pkgutil_2/package/__init__.py b/astroid/tests/testdata/python3/data/path_pkgutil_2/package/__init__.py
new file mode 100644
index 00000000..0bfb5a62
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkgutil_2/package/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python3/data/path_pkgutil_2/package/bar.py b/astroid/tests/testdata/python3/data/path_pkgutil_2/package/bar.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkgutil_2/package/bar.py
diff --git a/astroid/tests/testdata/python3/data/path_pkgutil_3/package/__init__.py b/astroid/tests/testdata/python3/data/path_pkgutil_3/package/__init__.py
new file mode 100644
index 00000000..0bfb5a62
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkgutil_3/package/__init__.py
@@ -0,0 +1,2 @@
+from pkgutil import extend_path
+__path__ = extend_path(__path__, __name__) \ No newline at end of file
diff --git a/astroid/tests/testdata/python3/data/path_pkgutil_3/package/baz.py b/astroid/tests/testdata/python3/data/path_pkgutil_3/package/baz.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/astroid/tests/testdata/python3/data/path_pkgutil_3/package/baz.py
diff --git a/astroid/tests/unittest_manager.py b/astroid/tests/unittest_manager.py
index 12674516..aa1fd400 100644
--- a/astroid/tests/unittest_manager.py
+++ b/astroid/tests/unittest_manager.py
@@ -22,6 +22,7 @@ import unittest
import six
+import astroid
from astroid import exceptions
from astroid import manager
from astroid.tests import resources
@@ -94,6 +95,24 @@ class AstroidManagerTest(resources.SysPathSetup,
self.manager.ast_from_module_name,
'unhandledModule')
+ def _test_ast_from_old_namespace_package_protocol(self, root):
+ origpath = sys.path[:]
+ paths = [resources.find('data/path_{}_{}'.format(root, index))
+ for index in range(1, 4)]
+ sys.path.extend(paths)
+ try:
+ for name in ('foo', 'bar', 'baz'):
+ module = self.manager.ast_from_module_name('package.' + name)
+ self.assertIsInstance(module, astroid.Module)
+ finally:
+ sys.path = origpath
+
+ def test_ast_from_namespace_pkgutil(self):
+ self._test_ast_from_old_namespace_package_protocol('pkgutil')
+
+ def test_ast_from_namespace_pkg_resources(self):
+ self._test_ast_from_old_namespace_package_protocol('pkg_resources')
+
def _test_ast_from_zip(self, archive):
origpath = sys.path[:]
sys.modules.pop('mypypa', None)