mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Make more examples in make_definitions
This commit is contained in:
@@ -1,10 +1,17 @@
|
|||||||
|
import textwrap
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from jedi import api
|
from jedi import api
|
||||||
|
|
||||||
|
|
||||||
def make_definitions():
|
def make_definitions():
|
||||||
return api.defined_names("""
|
"""
|
||||||
|
Return a list of definitions for parametrized tests.
|
||||||
|
|
||||||
|
:rtype: [jedi.api_classes.BaseDefinition]
|
||||||
|
"""
|
||||||
|
source = textwrap.dedent("""
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class C:
|
class C:
|
||||||
@@ -16,6 +23,20 @@ def make_definitions():
|
|||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
definitions = []
|
||||||
|
definitions += api.defined_names(source)
|
||||||
|
|
||||||
|
source += textwrap.dedent("""
|
||||||
|
variable = sys or C or x or f""")
|
||||||
|
lines = source.splitlines()
|
||||||
|
script = api.Script(source, len(lines), len('variable'), None)
|
||||||
|
definitions += script.definition()
|
||||||
|
|
||||||
|
script2 = api.Script(source, 4, len('class C'), None)
|
||||||
|
definitions += script2.related_names()
|
||||||
|
|
||||||
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('definition', make_definitions())
|
@pytest.mark.parametrize('definition', make_definitions())
|
||||||
def test_basedefinition_type(definition):
|
def test_basedefinition_type(definition):
|
||||||
|
|||||||
Reference in New Issue
Block a user