コード例 #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
ファイル: codeassisttest.py プロジェクト: DonJayamanne/rope
 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
ファイル: codeassisttest.py プロジェクト: DonJayamanne/rope
 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
ファイル: codeassisttest.py プロジェクト: DonJayamanne/rope
 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
ファイル: codeassisttest.py プロジェクト: DonJayamanne/rope
 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
ファイル: codeassisttest.py プロジェクト: DonJayamanne/rope
 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')])