Beispiel #1
0
def test_namedtuple_goto_definitions(Script):
    source = dedent("""
        from collections import namedtuple

        Foo = namedtuple('Foo', 'id timestamp gps_timestamp attributes')
        Foo""")

    from jedi.api import Script

    d1, = Script(source).goto_definitions()

    assert d1.get_line_code() == "class Foo(tuple):\n"
    assert d1.module_path is None
Beispiel #2
0
def test_namedtuple_infer(Script):
    source = dedent("""
        from collections import namedtuple

        Foo = namedtuple('Foo', 'id timestamp gps_timestamp attributes')
        Foo""")

    from jedi.api import Script

    d1, = Script(source).infer()

    assert d1.get_line_code() == "class Foo(tuple):\n"
    assert d1.module_path is None
    assert d1.docstring() == 'Foo(id, timestamp, gps_timestamp, attributes)'