def test_completion_docstring(): """ Jedi should follow imports in certain conditions """ c = Script('import jedi\njed').completions()[0] assert c.docstring(fast=False) == cleandoc(jedi_doc) c = Script('import jedi\njedi.Scr').completions()[0] assert c.docstring(raw=True, fast=False) == cleandoc(Script.__doc__)
def test_completion_docstring(): """ Jedi should follow imports in certain conditions """ def docstr(src, result): c = Script(src).completions()[0] assert c.docstring(raw=True, fast=False) == cleandoc(result) c = Script('import jedi\njed').completions()[0] assert c.docstring(fast=False) == cleandoc(jedi_doc) docstr('import jedi\njedi.Scr', cleandoc(Script.__doc__)) docstr('abcd=3;abcd', '') docstr('"hello"\nabcd=3\nabcd', 'hello') # It works with a ; as well. docstr('"hello"\nabcd=3;abcd', 'hello') # Shouldn't work with a tuple. docstr('"hello",0\nabcd=3\nabcd', '')
def test_completion_docstring(): """ Jedi should follow imports in certain conditions """ def docstr(src, result): c = Script(src).completions()[0] assert c.docstring(raw=True, fast=False) == cleandoc(result) c = Script('import jedi\njed').completions()[0] assert c.docstring(fast=False) == cleandoc(jedi_doc) docstr('import jedi\njedi.Scr', cleandoc(Script.__doc__)) docstr('abcd=3;abcd', '') docstr('"hello"\nabcd=3\nabcd', '') docstr(dedent(''' def x(): "hello" 0 x'''), 'hello' ) docstr(dedent(''' def x(): "hello";0 x'''), 'hello' ) # Shouldn't work with a tuple. docstr(dedent(''' def x(): "hello",0 x'''), '' ) # Should also not work if we rename something. docstr(dedent(''' def x(): "hello" y = x y'''), '' )
def docstr(src, result): c = Script(src).completions()[0] assert c.docstring(raw=True, fast=False) == cleandoc(result)
def test_time_docstring(): import time comp, = Script('import time\ntime.sleep').completions() assert comp.docstring() == time.sleep.__doc__