forked from VimPlug/jedi
failing import tests for #280
This commit is contained in:
@@ -75,7 +75,10 @@ def setup_readline(namespace=__main__.__dict__):
|
|||||||
# use the "default" completion with ``getattr`` if
|
# use the "default" completion with ``getattr`` if
|
||||||
# possible.
|
# possible.
|
||||||
path, dot, like = interpreter._get_completion_parts()
|
path, dot, like = interpreter._get_completion_parts()
|
||||||
if not path or re.match('^[\w][\w\d.]*$', path):
|
# Shouldn't be an import statement and just a simple path
|
||||||
|
# with dots.
|
||||||
|
if not re.match('^\s*(import|from) ', text) \
|
||||||
|
and (not path or re.match('^[\w][\w\d.]*$', path)):
|
||||||
paths = path.split('.') if path else []
|
paths = path.split('.') if path else []
|
||||||
namespaces = (namespace, builtins.__dict__)
|
namespaces = (namespace, builtins.__dict__)
|
||||||
for p in paths:
|
for p in paths:
|
||||||
|
|||||||
@@ -46,8 +46,16 @@ class TestSetupReadline():
|
|||||||
del self.namespace['sys']
|
del self.namespace['sys']
|
||||||
del self.namespace['os']
|
del self.namespace['os']
|
||||||
|
|
||||||
|
def test_import(self):
|
||||||
|
assert self.completions('import keyword') == ['keyword']
|
||||||
|
|
||||||
def test_colorama(self):
|
def test_colorama(self):
|
||||||
"""Only test it if colorama library is available"""
|
"""
|
||||||
|
Only test it if colorama library is available.
|
||||||
|
|
||||||
|
This module is being tested because it uses ``setattr`` at some point,
|
||||||
|
which Jedi doesn't understand, but it should still work in the REPL.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
# if colorama is installed
|
# if colorama is installed
|
||||||
import colorama
|
import colorama
|
||||||
@@ -56,4 +64,5 @@ class TestSetupReadline():
|
|||||||
else:
|
else:
|
||||||
self.namespace['colorama'] = colorama
|
self.namespace['colorama'] = colorama
|
||||||
assert self.completions('colorama')
|
assert self.completions('colorama')
|
||||||
|
assert self.completions('colorama.Fore.BLACK') == ['colorama.Fore.BLACK']
|
||||||
del self.namespace['colorama']
|
del self.namespace['colorama']
|
||||||
|
|||||||
Reference in New Issue
Block a user