1
0
forked from VimPlug/jedi

Merge pull request #1313 from CXuesong/master

get_module_names should include top-level async functions when all_scopes=False.
This commit is contained in:
Dave Halter
2019-04-13 00:43:58 +02:00
committed by GitHub
2 changed files with 40 additions and 0 deletions

View File

@@ -95,6 +95,43 @@ class TestDefinedNames(TestCase):
self.assert_definition_names(C_subdefs, ['h'])
self.assert_definition_names(foo_subdefs, ['x', 'bar'])
def test_async_stmt_with_all_scopes_false(self):
definitions = self.check_defined_names("""
from module import f
import asyncio
g = f(f)
class C:
h = g
def __init__(self):
pass
async def __aenter__(self):
pass
def foo(x=a):
bar = x
return bar
async def async_foo(duration):
async def wait():
await asyncio.sleep(100)
for i in range(duration//100):
await wait()
return duration//100*100
async with C() as cinst:
d = cinst
""", ['f', 'asyncio', 'g', 'C', 'foo', 'async_foo', 'cinst', 'd'])
C_subdefs = definitions[3].defined_names()
foo_subdefs = definitions[4].defined_names()
async_foo_subdefs = definitions[5].defined_names()
cinst_subdefs = definitions[6].defined_names()
self.assert_definition_names(C_subdefs, ['h', '__init__', '__aenter__'])
self.assert_definition_names(foo_subdefs, ['x', 'bar'])
self.assert_definition_names(async_foo_subdefs, ['duration', 'wait', 'i'])
# We treat d as a name outside `async with` block
self.assert_definition_names(cinst_subdefs, [])
def test_follow_imports(environment):
# github issue #344