def test_object_path_global(self): code = 'GLOBAL_VARIABLE = 42\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 1) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals(result, [(mod_path, 'MODULE'), ('GLOBAL_VARIABLE', 'VARIABLE')])
def test_object_path_variable(self): code = 'def bar(a):\n' \ ' x = a + 42\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 17) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals(result, [(mod_path, 'MODULE'), ('bar', 'FUNCTION'), ('x', 'VARIABLE')])
def test_object_path_attribute(self): code = 'class Foo(object):\n' \ ' attr = 42\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 24) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals(result, [(mod_path, 'MODULE'), ('Foo', 'CLASS'), ('attr', 'VARIABLE')])
def test_object_path_global(self): code = 'GLOBAL_VARIABLE = 42\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 1) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals( result, [(mod_path, 'MODULE'), ('GLOBAL_VARIABLE', 'VARIABLE')])
def test_object_path_method_parameter(self): code = 'class Foo(object):\n' \ ' def bar(self, a, b, c):\n' \ ' pass\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 41) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals(result, [(mod_path, 'MODULE'), ('Foo', 'CLASS'), ('bar', 'FUNCTION'), ('b', 'PARAMETER')])
def test_object_path_subclass(self): code = 'class Foo(object):\n' \ ' class Bar(object):\n' \ ' pass\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 30) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals(result, [(mod_path, 'MODULE'), ('Foo', 'CLASS'), ('Bar', 'CLASS')])
def test_object_path_variable(self): code = 'def bar(a):\n' \ ' x = a + 42\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 17) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals( result, [(mod_path, 'MODULE'), ('bar', 'FUNCTION'), ('x', 'VARIABLE')])
def test_object_path_attribute(self): code = 'class Foo(object):\n' \ ' attr = 42\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 24) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals( result, [(mod_path, 'MODULE'), ('Foo', 'CLASS'), ('attr', 'VARIABLE')])
def test_object_path_method_parameter(self): code = 'class Foo(object):\n' \ ' def bar(self, a, b, c):\n' \ ' pass\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 41) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals( result, [(mod_path, 'MODULE'), ('Foo', 'CLASS'), ('bar', 'FUNCTION'), ('b', 'PARAMETER')])
def test_object_path_subclass(self): code = 'class Foo(object):\n' \ ' class Bar(object):\n' \ ' pass\n' resource = testutils.create_module(self.project, 'mod') resource.write(code) result = get_canonical_path(self.project, resource, 30) mod_path = os.path.join(self.project.address, 'mod.py') self.assertEquals( result, [(mod_path, 'MODULE'), ('Foo', 'CLASS'), ('Bar', 'CLASS')])