Beispiel #1
0
 def test_find_returns_most_upper_definition(self):
     source = parse(
         "x = 1",
         "def foo():",
         "   x = 2",
     )
     add_variable_context(source)
     definition = source.scopes.find("x")
     assert definition.lineno == 1
Beispiel #2
0
def parse(*args):
    source = ast.parse("\n".join(args))
    add_variable_context(source)
    add_scope_context(source)
    return source