forked from VimPlug/jedi
Don't use the old setup_function/teardown_function pytest stuff. It's very implicit and hard to understand.
This commit is contained in:
@@ -460,8 +460,7 @@ class _Importer(object):
|
|||||||
def follow_file_system(self):
|
def follow_file_system(self):
|
||||||
# Handle "magic" Flask extension imports:
|
# Handle "magic" Flask extension imports:
|
||||||
# ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
|
# ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
|
||||||
if len(self.import_path) > 2 and \
|
if len(self.import_path) > 2 and self.str_import_path()[:2] == ('flask', 'ext'):
|
||||||
[str(part) for part in self.import_path[:2]] == ['flask', 'ext']:
|
|
||||||
orig_path = tuple(self.import_path)
|
orig_path = tuple(self.import_path)
|
||||||
part = orig_path[2]
|
part = orig_path[2]
|
||||||
pos = (part._line, part._column)
|
pos = (part._line, part._column)
|
||||||
@@ -634,7 +633,7 @@ class _Importer(object):
|
|||||||
if self.import_path:
|
if self.import_path:
|
||||||
for scope in self.follow(evaluator):
|
for scope in self.follow(evaluator):
|
||||||
# flask
|
# flask
|
||||||
if self.import_path == ('flask', 'ext'):
|
if self.str_import_path() == ('flask', 'ext'):
|
||||||
# List Flask extensions like ``flask_foo``
|
# List Flask extensions like ``flask_foo``
|
||||||
for mod in self._get_module_names():
|
for mod in self._get_module_names():
|
||||||
modname = str(mod)
|
modname = str(mod)
|
||||||
|
|||||||
@@ -28,16 +28,6 @@ def test_import_not_in_sys_path():
|
|||||||
assert a[0].name == 'str'
|
assert a[0].name == 'str'
|
||||||
|
|
||||||
|
|
||||||
def setup_function(function):
|
|
||||||
sys.path.append(os.path.join(
|
|
||||||
os.path.dirname(__file__), 'flask-site-packages'))
|
|
||||||
|
|
||||||
|
|
||||||
def teardown_function(function):
|
|
||||||
path = os.path.join(os.path.dirname(__file__), 'flask-site-packages')
|
|
||||||
sys.path.remove(path)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("script,name", [
|
@pytest.mark.parametrize("script,name", [
|
||||||
("from flask.ext import foo; foo.", "Foo"), # flask_foo.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 bar; bar.", "Bar"), # flaskext/bar.py
|
||||||
@@ -55,4 +45,9 @@ def teardown_function(function):
|
|||||||
def test_flask_ext(script, name):
|
def test_flask_ext(script, name):
|
||||||
"""flask.ext.foo is really imported from flaskext.foo or flask_foo.
|
"""flask.ext.foo is really imported from flaskext.foo or flask_foo.
|
||||||
"""
|
"""
|
||||||
assert name in [c.name for c in jedi.Script(script).completions()]
|
path = os.path.join(os.path.dirname(__file__), 'flask-site-packages')
|
||||||
|
sys.path.append(path)
|
||||||
|
try:
|
||||||
|
assert name in [c.name for c in jedi.Script(script).completions()]
|
||||||
|
finally:
|
||||||
|
sys.path.remove(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user