1
0
forked from VimPlug/jedi

Use locals() for tests in TestInterpreterAPI

It is better to check that Interpreter does not fail with the
real name space.  Previously the doctest using locals() failed
because of the bug in _import_raw_namespace.
This commit is contained in:
Takafumi Arakaki
2013-03-03 13:35:48 +01:00
parent a93016db1b
commit dc47d15de0
2 changed files with 13 additions and 9 deletions

View File

@@ -576,17 +576,18 @@ class Interpreter(Script):
"""
scope = self._parser.scope
for (variable, obj) in raw_namespace.items():
objname = getattr(obj, '__name__', None)
# Import functions and classes
module = getattr(obj, '__module__', None)
if module:
fakeimport = self._make_fakeimport(module, obj.__name__,
variable)
if module and objname:
fakeimport = self._make_fakeimport(module, objname, variable)
scope.add_import(fakeimport)
continue
# Import modules
if getattr(obj, '__file__', None):
fakeimport = self._make_fakeimport(obj.__name__)
if getattr(obj, '__file__', None) and objname:
fakeimport = self._make_fakeimport(objname)
scope.add_import(fakeimport)
continue