mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Merge branch 'master' into relative-import
This commit is contained in:
@@ -206,6 +206,24 @@ def test_numpydoc_parameters_set_of_values():
|
||||
assert 'capitalize' in names
|
||||
assert 'numerator' in names
|
||||
|
||||
@pytest.mark.skipif(numpydoc_unavailable,
|
||||
reason='numpydoc module is unavailable')
|
||||
def test_numpydoc_parameters_set_single_value():
|
||||
"""
|
||||
This is found in numpy masked-array I'm not too sure what this means but should not crash
|
||||
"""
|
||||
s = dedent('''
|
||||
def foobar(x, y):
|
||||
"""
|
||||
Parameters
|
||||
----------
|
||||
x : {var}, optional
|
||||
"""
|
||||
x.''')
|
||||
names = [c.name for c in jedi.Script(s).complete()]
|
||||
# just don't crash
|
||||
assert names == []
|
||||
|
||||
|
||||
@pytest.mark.skipif(numpydoc_unavailable,
|
||||
reason='numpydoc module is unavailable')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from parso.cache import parser_cache
|
||||
|
||||
from test.helpers import root_dir
|
||||
from jedi.api.project import Project
|
||||
@@ -64,6 +65,17 @@ def test_goto_import(Script):
|
||||
assert not d.is_stub()
|
||||
|
||||
|
||||
def test_stub_get_line_code(Script):
|
||||
code = 'from abc import ABC; ABC'
|
||||
script = Script(code)
|
||||
d, = script.goto(only_stubs=True)
|
||||
assert d.get_line_code() == 'class ABC(metaclass=ABCMeta): ...\n'
|
||||
del parser_cache[script._inference_state.latest_grammar._hashed][d.module_path]
|
||||
d, = Script(path=d.module_path).goto(d.line, d.column, only_stubs=True)
|
||||
assert d.is_stub()
|
||||
assert d.get_line_code() == 'class ABC(metaclass=ABCMeta): ...\n'
|
||||
|
||||
|
||||
def test_os_stat_result(Script):
|
||||
d, = Script('import os; os.stat_result').goto()
|
||||
assert d.is_stub()
|
||||
|
||||
@@ -489,3 +489,9 @@ def test_relative_imports_without_path_and_setup_py(
|
||||
assert n.name == name
|
||||
assert n.type == 'module'
|
||||
assert n.line == 1
|
||||
|
||||
|
||||
def test_import_recursion(Script):
|
||||
path = get_example_dir('import-recursion', "cq_example.py")
|
||||
for c in Script(path=path).complete(3, 3):
|
||||
c.docstring()
|
||||
|
||||
@@ -340,3 +340,20 @@ def test_overload(Script, code):
|
||||
x1, x2 = Script(code, path=os.path.join(dir_, 'foo.py')).get_signatures()
|
||||
assert x1.to_string() == 'with_overload(x: int, y: int) -> float'
|
||||
assert x2.to_string() == 'with_overload(x: str, y: list) -> float'
|
||||
|
||||
|
||||
def test_enum(Script):
|
||||
script = Script('''\
|
||||
from enum import Enum
|
||||
|
||||
class Planet(Enum):
|
||||
MERCURY = (3.303e+23, 2.4397e6)
|
||||
VENUS = (4.869e+24, 6.0518e6)
|
||||
|
||||
def __init__(self, mass, radius):
|
||||
self.mass = mass # in kilograms
|
||||
self.radius = radius # in meters
|
||||
|
||||
Planet.MERCURY''')
|
||||
completion, = script.complete()
|
||||
assert not completion.get_signatures()
|
||||
|
||||
Reference in New Issue
Block a user