コード例 #1
0
ファイル: test_idehelper.py プロジェクト: tdavis/pysmell
    def testInferClassYouDontKnowAbout(self):
        source = dedent("""\
            class NewClass(object):
                def sth(self):
                    self.
        
        """)
        pathParts = ['TestData', 'PackageB', 'NewModule.py'] # TestData/PackageB contains an __init__.py file
        relPath = os.path.join(*pathParts)
        inferred, parents = inferClass(relPath, getSafeTree(source, 3), 3, NESTEDDICT, None)
        self.assertEquals(inferred, 'PackageB.NewModule.NewClass')
        self.assertEquals(parents, ['object'])

        cwd = os.getcwd()
        pathParts = [cwd, 'TestData', 'PackageB', 'NewModule.py'] # TestData/PackageB contains an __init__.py file
        absPath = os.path.join(*pathParts)
        inferred, parents = inferClass(absPath, getSafeTree(source, 3), 3, NESTEDDICT, None)
        self.assertEquals(inferred, 'PackageB.NewModule.NewClass')
        self.assertEquals(parents, ['object'])
コード例 #2
0
ファイル: test_idehelper.py プロジェクト: tatwright/pysmell
    def testInferClassYouDontKnowAbout(self):
        source = dedent("""\
            class NewClass(object):
                def sth(self):
                    self.
        
        """)
        pathParts = ['TestData', 'PackageB', 'NewModule.py'] # TestData/PackageB contains an __init__.py file
        relPath = os.path.join(*pathParts)
        inferred, parents = inferClass(relPath, source, 3, NESTEDDICT, None)
        self.assertEquals(inferred, 'PackageB.NewModule.NewClass')
        self.assertEquals(parents, ['object'])

        cwd = os.getcwd()
        pathParts = [cwd, 'TestData', 'PackageB', 'NewModule.py'] # TestData/PackageB contains an __init__.py file
        absPath = os.path.join(*pathParts)
        inferred, parents = inferClass(absPath, source, 3, NESTEDDICT, None)
        self.assertEquals(inferred, 'PackageB.NewModule.NewClass')
        self.assertEquals(parents, ['object'])
コード例 #3
0
ファイル: test_idehelper.py プロジェクト: tatwright/pysmell
 def testInferClassRelative(self):
     source = dedent("""\
         class Class(object):
             def sth(self):
                 self.
     
     """)
     pathParts = ["Nested", "Package", "Module.py"]
     relPath = os.path.join(*pathParts)
     inferred, _ = inferClass(relPath, source, 3, NESTEDDICT, None)
     self.assertEquals(inferred, 'Nested.Package.Module.Class')
コード例 #4
0
ファイル: test_idehelper.py プロジェクト: tdavis/pysmell
 def testInferClassRelative(self):
     source = dedent("""\
         class Class(object):
             def sth(self):
                 self.
     
     """)
     pathParts = ["Nested", "Package", "Module.py"]
     relPath = os.path.join(*pathParts)
     inferred, _ = inferClass(relPath, getSafeTree(source, 3), 3, NESTEDDICT, None)
     self.assertEquals(inferred, 'Nested.Package.Module.Class')
コード例 #5
0
ファイル: test_idehelper.py プロジェクト: tatwright/pysmell
 def testInferClassParentsWithPointersToStar(self):
     source = dedent("""\
         from Star import Class
         class Bother(Class):
             def sth(self):
                 self.
     
     """)
     klass, parents = inferClass(os.path.join('TestData', 'PackageA', 'Module.py'), source,
                         4, NESTEDDICT)
     self.assertEquals(klass, 'PackageA.Module.Bother')
     self.assertEquals(parents, ['Nested.Package.Module.Class'])
コード例 #6
0
ファイル: test_idehelper.py プロジェクト: tatwright/pysmell
 def testInferUnknownClassParents(self):
     source = dedent("""\
         from Nested.Package.Module import Class
         class Other(Class):
             def sth(self):
                 self.
     
     """)
     klass, parents = inferClass(os.path.join('TestData', 'PackageA', 'Module.py'), source,
                         4, NESTEDDICT)
     self.assertEquals(klass, 'PackageA.Module.Other')
     self.assertEquals(parents, ['Nested.Package.Module.Class'])
コード例 #7
0
ファイル: test_idehelper.py プロジェクト: goj/pysmell
 def testInferClassParentsWithPointers(self):
     source = dedent("""\
         from Another import Thing
         class Bother(Thing):
             def sth(self):
                 self.
     
     """)
     klass, parents = inferClass(os.path.join('TestData', 'PackageA', 'Module.py'),
         getSafeTree(source, 4), 4, NESTEDDICT)
     self.assertEquals(klass, 'PackageA.Module.Bother')
     self.assertEquals(parents, ['Nested.Package.Module.Class'])
コード例 #8
0
ファイル: test_idehelper.py プロジェクト: tdavis/pysmell
 def testInferClassParentsWithPointersToStar(self):
     source = dedent("""\
         from Star import Class
         class Bother(Class):
             def sth(self):
                 self.
     
     """)
     klass, parents = inferClass(os.path.join('TestData', 'PackageA', 'Module.py'),
         getSafeTree(source, 4), 4, NESTEDDICT)
     self.assertEquals(klass, 'PackageA.Module.Bother')
     self.assertEquals(parents, ['Nested.Package.Module.Class'])
コード例 #9
0
 def testInferUnknownClassParents(self):
     source = dedent("""\
         from Nested.Package.Module import Class
         class Other(Class):
             def sth(self):
                 self.
     
     """)
     klass, parents = inferClass(
         os.path.join('TestData', 'PackageA', 'Module.py'),
         getSafeTree(source, 4), 4, NESTEDDICT)
     self.assertEqual(klass, 'PackageA.Module.Other')
     self.assertEqual(parents, ['Nested.Package.Module.Class'])
コード例 #10
0
ファイル: test_idehelper.py プロジェクト: tatwright/pysmell
 def testInferClassAbsolute(self):
     source = dedent("""\
         class Class(object):
             def sth(self):
                 self.
     
     """)
     pathParts = ["DevFolder", "BlahBlah", "Nested", "Package", "Module.py"]
     if os.name == 'posix':
         pathParts.insert(0, "/")
     else:
         pathParts.insert(0, "C:")
     absPath = os.path.join(*pathParts)
     inferred, _ = inferClass(absPath, source, 3, NESTEDDICT, None)
     self.assertEquals(inferred, 'Nested.Package.Module.Class')
コード例 #11
0
ファイル: test_idehelper.py プロジェクト: tdavis/pysmell
 def testInferClassAbsolute(self):
     source = dedent("""\
         class Class(object):
             def sth(self):
                 self.
     
     """)
     pathParts = ["DevFolder", "BlahBlah", "Nested", "Package", "Module.py"]
     if os.name == 'posix':
         pathParts.insert(0, "/")
     else:
         pathParts.insert(0, "C:")
     absPath = os.path.join(*pathParts)
     inferred, _ = inferClass(absPath, getSafeTree(source, 3), 3, NESTEDDICT, None)
     self.assertEquals(inferred, 'Nested.Package.Module.Class')