예제 #1
0
 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')])
예제 #2
0
 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')])
예제 #3
0
 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')])
예제 #4
0
 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')])
예제 #5
0
 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')])
예제 #6
0
 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')])
예제 #7
0
 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')])
예제 #8
0
 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')])
예제 #9
0
 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')])
예제 #10
0
 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')])