mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix get_line_code for stubs
This commit is contained in:
@@ -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][str(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()
|
||||
|
||||
Reference in New Issue
Block a user