Make sure code_lines works on stubs, even if they are builtins

This commit is contained in:
Dave Halter
2019-12-01 19:10:08 +01:00
parent 582df2f76d
commit 6ffeea7eea
4 changed files with 20 additions and 2 deletions

View File

@@ -170,7 +170,7 @@ def test_get_line_code(Script):
return Script(source, line=line).completions()[0].get_line_code(**kwargs)
# On builtin
assert get_line_code('') == ''
assert get_line_code('abs') == 'def abs(__n: SupportsAbs[_T]) -> _T: ...\n'
# On custom code
first_line = 'def foo():\n'
@@ -188,6 +188,13 @@ def test_get_line_code(Script):
assert get_line_code(code, line=2, after=3, before=3) == code
def test_get_line_code_on_builtin(Script, disable_typeshed):
abs_ = Script('abs').completions()[0]
assert abs_.name == 'abs'
assert abs_.get_line_code() == ''
assert abs_.line is None
def test_goto_assignments_follow_imports(Script):
code = dedent("""
import inspect