mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Make a separate test case.
This commit is contained in:
@@ -80,6 +80,22 @@ class TestDefinedNames(TestCase):
|
|||||||
self.assert_definition_names(subsubdefs[0].defined_names(), ['f'])
|
self.assert_definition_names(subsubdefs[0].defined_names(), ['f'])
|
||||||
|
|
||||||
def test_class_fields_with_all_scopes_false(self):
|
def test_class_fields_with_all_scopes_false(self):
|
||||||
|
definitions = self.check_defined_names("""
|
||||||
|
from module import f
|
||||||
|
g = f(f)
|
||||||
|
class C:
|
||||||
|
h = g
|
||||||
|
|
||||||
|
def foo(x=a):
|
||||||
|
bar = x
|
||||||
|
return bar
|
||||||
|
""", ['f', 'g', 'C', 'foo'])
|
||||||
|
C_subdefs = definitions[-2].defined_names()
|
||||||
|
foo_subdefs = definitions[-1].defined_names()
|
||||||
|
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("""
|
definitions = self.check_defined_names("""
|
||||||
from module import f
|
from module import f
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -103,14 +119,19 @@ class TestDefinedNames(TestCase):
|
|||||||
for i in range(duration//100):
|
for i in range(duration//100):
|
||||||
await wait()
|
await wait()
|
||||||
return duration//100*100
|
return duration//100*100
|
||||||
""", ['f', 'asyncio', 'g', 'C', 'foo', 'async_foo'])
|
|
||||||
C_subdefs = definitions[-3].defined_names()
|
async with C() as cinst:
|
||||||
foo_subdefs = definitions[-2].defined_names()
|
d = cinst
|
||||||
async_foo_subdefs = definitions[-1].defined_names()
|
""", ['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(C_subdefs, ['h', '__init__', '__aenter__'])
|
||||||
self.assert_definition_names(foo_subdefs, ['x', 'bar'])
|
self.assert_definition_names(foo_subdefs, ['x', 'bar'])
|
||||||
self.assert_definition_names(async_foo_subdefs, ['duration', 'wait', 'i'])
|
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):
|
def test_follow_imports(environment):
|
||||||
# github issue #344
|
# github issue #344
|
||||||
|
|||||||
Reference in New Issue
Block a user