Esempio n. 1
0
def test_module_scope(project):
    result = get_scope_at(project, cleantabs("""
        test1 = 1

        test2 = 2
    """), 2).fullname

    assert result == ''
Esempio n. 2
0
def test_method_scope_must_know_self_type(project):
    scope = get_scope_at(project, cleantabs('''
        class Foo(object):
            def foo(self):
                return self

            def bar(self):
                pass
    '''), 3)

    obj = infer('self', scope, 7)
    assert 'bar' in obj
Esempio n. 3
0
def test_class_must_contain_objects_defined_in_glade_file(project):
    project.register_hook('supplement.hooks.pygtk')
    source, _ = get_source_and_pos('''
        class Window(object):
            """glade-file: tests/pygtktest/sample.glade"""

            def foo(self):
                pass
    ''')

    scope = get_scope_at(project, source, 5, 'test.py')

    result = infer('self', scope, 5)
    assert 'window1' in result
    assert 'vbox1' in result

    result = infer('self.window1', scope, 5)
    assert 'set_title' in result

    result = infer('self.vbox1', scope, 5)
    assert 'pack_start' in result
Esempio n. 4
0
 def check(line, name):
     result = get_scope_at(project, source, line, continous=cont).fullname
     assert result == name, "[%s] must be [%s] at line %d" % (result, name, line)
Esempio n. 5
0
 def get_scope(self, path, source, lineno, filename, continous):
     return get_scope_at(
         self.get_project(path), sanitize_encoding(source), lineno,
             filename, continous=continous).fullname