diff --git a/jedi/evaluate/imports.py b/jedi/evaluate/imports.py index ec3ff0ca..8a0da9c4 100644 --- a/jedi/evaluate/imports.py +++ b/jedi/evaluate/imports.py @@ -528,7 +528,7 @@ class _Importer(object): options = ('declare_namespace(__name__)', 'extend_path(__path__') if options[0] in content or options[1] in content: # It is a namespace, now try to find the rest of the modules. - return follow_path(iter(import_path), sys.path) + return follow_path((str(i) for i in import_path), sys.path) return [] def _follow_sys_path(self, sys_path): @@ -647,7 +647,6 @@ class _Importer(object): if os.path.isdir(flaskext): names += self._get_module_names([flaskext]) - # TODO delete # namespace packages if isinstance(scope, pr.Module) and scope.path.endswith('__init__.py'): pkg_path = os.path.dirname(scope.path) @@ -661,8 +660,10 @@ class _Importer(object): # os.path is a hardcoded exception, because it's a # ``sys.modules`` modification. names.append(self._generate_name('path')) + continue + # TODO delete if False and not self.import_stmt.from_names or False and self.is_partial_import: # from_names must be defined to access module # values plus a partial import means that there diff --git a/pytest.ini b/pytest.ini index 9626144c..1168b452 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,7 +2,7 @@ addopts = --doctest-modules # Ignore broken files in blackbox test directories -norecursedirs = .* docs completion refactor absolute_import namespace_package scripts extensions speed static_analysis +norecursedirs = .* docs completion refactor absolute_import namespace_package scripts extensions speed static_analysis not_in_sys_path buildout_project # Activate `clean_jedi_cache` fixture for all tests. This should be # fine as long as we are using `clean_jedi_cache` as a session scoped diff --git a/test/test_evaluate/test_imports.py b/test/test_evaluate/test_imports.py index e695df79..6c4d293c 100644 --- a/test/test_evaluate/test_imports.py +++ b/test/test_evaluate/test_imports.py @@ -39,10 +39,10 @@ def teardown_function(function): @pytest.mark.parametrize("script,name", [ - ("from flask.ext import foo; foo.", "Foo"), # flask_foo.py - ("from flask.ext import bar; bar.", "Bar"), # flaskext/bar.py - ("from flask.ext import baz; baz.", "Baz"), # flask_baz/__init__.py - ("from flask.ext import moo; moo.", "Moo"), # flaskext/moo/__init__.py + ("from flask.ext import foo; foo.", "Foo"), # flask_foo.py + ("from flask.ext import bar; bar.", "Bar"), # flaskext/bar.py + ("from flask.ext import baz; baz.", "Baz"), # flask_baz/__init__.py + ("from flask.ext import moo; moo.", "Moo"), # flaskext/moo/__init__.py ("from flask.ext.", "foo"), ("from flask.ext.", "bar"), ("from flask.ext.", "baz"), @@ -56,4 +56,3 @@ def test_flask_ext(script, name): """flask.ext.foo is really imported from flaskext.foo or flask_foo. """ assert name in [c.name for c in jedi.Script(script).completions()] - diff --git a/test/test_evaluate/test_namespace_package.py b/test/test_evaluate/test_namespace_package.py index f39f58ef..c9e6cb97 100644 --- a/test/test_evaluate/test_namespace_package.py +++ b/test/test_evaluate/test_namespace_package.py @@ -31,7 +31,7 @@ def test_namespace_package(): names = [str(c.name) for c in completions] # str because of unicode compare = ['foo', 'ns1_file', 'ns1_folder', 'ns2_folder', 'ns2_file'] # must at least contain these items, other items are not important - assert not (set(compare) - set(names)) + assert set(compare) == set(names) tests = { 'from pkg import ns2_folder as x': 'ns2_folder!',