# Path: supplement/evaluator.py
# def infer(string, scope, lineno=None):
#     tree = ast.parse(string, '<string>', 'eval')
# 
#     if lineno:
#         ast.increment_lineno(tree, lineno-1)
# 
#     return Evaluator().process(tree, scope)
# 
# Path: supplement/names.py
# class ArgumentName(GetObjectDelegate):
#     def __init__(self, scope, index, name):
#         self.scope = scope
#         self.index = index
#         self.name = name
# 
#     def get_object(self):
#         try:
#             return self._object
#         except AttributeError:
#             pass
# 
#         if self.index == 0 and self.scope.parent.type == 'class':
#             from .objects import FakeInstanceObject
#             self._object = FakeInstanceObject(self.scope.parent.cls)
#         else:
#             args = self.scope.project.calldb.get_args_for_scope(self.scope)
#             if args:
#                 index = self.index
#                 if self.scope.parent.type == 'class':
#                     index -= 1
# 
#                 try:
#                     obj = args[index]
#                 except IndexError:
#                     obj = UnknownObject()
#             else:
#                 obj = UnknownObject()
# 
#             self._object = obj
# 
#         return self._object
# 
#     def find_attr_assignments(self):
#         return AttributesAssignsExtractor().process(self.name, self.scope, self.scope.node)
# 
# Path: tests/helpers.py
# def pytest_funcarg__project(request):
#     for crap_module in ('toimport', 'package'):
#         if crap_module in sys.modules:
#             del sys.modules[crap_module]
# 
#     p = Project('.')
#     p.create_module = create_module.__get__(p, Project)
#     p.create_scope = create_scope.__get__(p, Project)
#     p.set_root = set_project_root.__get__(p, Project)
#     return p


from supplement.evaluator import infer
from supplement.names import ArgumentName
from .helpers import pytest_funcarg__project

    obj = scope1.get_name('f', line1)
    assert obj

    result = scope2.get_names(line2)
    assert 'f' not in result

def test_name_in_list_comprehension(project):
    scope, line = project.create_scope('''
        data = [(x, y) for x in (1, 2, 3) for y in ("1", "2", "3")]
        for a, b in data:
            |
            pass
    ''')

    obj = scope.get_name('data', line)
    assert 'append' in  obj

    obj = scope.get_name('a', line)
    assert 'numerator' in  obj

    obj = scope.get_name('b', line)
    assert 'split' in  obj

def test_name_in_generator_expression(project):
    scope, line = project.create_scope('''
        def foo(arg):
            return arg

        for a, b in foo((x, y) for x in (1, 2, 3) for y in ("1", "2", "3")):

# Path: supplement/evaluator.py
# def infer(string, scope, lineno=None):
#     tree = ast.parse(string, '<string>', 'eval')
# 
#     if lineno:
#         ast.increment_lineno(tree, lineno-1)
# 
#     return Evaluator().process(tree, scope)
# 
# Path: supplement/names.py
# class ArgumentName(GetObjectDelegate):
#     def __init__(self, scope, index, name):
#         self.scope = scope
#         self.index = index
#         self.name = name
# 
#     def get_object(self):
#         try:
#             return self._object
#         except AttributeError:
#             pass
# 
#         if self.index == 0 and self.scope.parent.type == 'class':
#             from .objects import FakeInstanceObject
#             self._object = FakeInstanceObject(self.scope.parent.cls)
#         else:
#             args = self.scope.project.calldb.get_args_for_scope(self.scope)
#             if args:
#                 index = self.index
#                 if self.scope.parent.type == 'class':
#                     index -= 1
# 
#                 try:
#                     obj = args[index]
#                 except IndexError:
#                     obj = UnknownObject()
#             else:
#                 obj = UnknownObject()
# 
#             self._object = obj
# 
#         return self._object
# 
#     def find_attr_assignments(self):
#         return AttributesAssignsExtractor().process(self.name, self.scope, self.scope.node)
# 
# Path: tests/helpers.py
# def pytest_funcarg__project(request):
#     for crap_module in ('toimport', 'package'):
#         if crap_module in sys.modules:
#             del sys.modules[crap_module]
# 
#     p = Project('.')
#     p.create_module = create_module.__get__(p, Project)
#     p.create_scope = create_scope.__get__(p, Project)
#     p.set_root = set_project_root.__get__(p, Project)
#     return p


# Path: tests/test_names.py
from supplement.evaluator import infer
from supplement.names import ArgumentName
from .helpers import pytest_funcarg__project


    obj = scope1.get_name('f', line1)
    assert obj

    result = scope2.get_names(line2)
    assert 'f' not in result

def test_name_in_list_comprehension(project):
    scope, line = project.create_scope('''
        data = [(x, y) for x in (1, 2, 3) for y in ("1", "2", "3")]
        for a, b in data:
            |
            pass
    ''')

    obj = scope.get_name('data', line)
    assert 'append' in  obj

    obj = scope.get_name('a', line)
    assert 'numerator' in  obj

    obj = scope.get_name('b', line)
    assert 'split' in  obj

def test_name_in_generator_expression(project):
    scope, line = project.create_scope('''
        def foo(arg):
            return arg

        for a, b in foo((x, y) for x in (1, 2, 3) for y in ("1", "2", "3")):

            |