Esempio n. 1
0
 def test_getsSingleLinePassStatementWhenWholeLineIsHighlighted(self):
     src = trimLines("""
     class MyClass:
         def myMethod(self):
             pass
     """)
     sourcenode = writeSourceAndCreateNode(src)
     em = ExtractMethod(sourcenode, coords(3, 0), coords(3, 12), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(len(em.extractedLines), 1)
     self.assertEqual(em.extractedLines[0], "pass\n")
Esempio n. 2
0
 def test_getsSingleLinePassStatementWhenWholeLineIsHighlighted(self):
     src=trimLines("""
     class MyClass:
         def myMethod(self):
             pass
     """)
     sourcenode = writeSourceAndCreateNode(src)
     em = ExtractMethod(sourcenode, coords(3, 0),
                          coords(3, 12), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(len(em.extractedLines), 1)
     self.assertEqual(em.extractedLines[0], "pass\n")
Esempio n. 3
0
 def test_getsHighlightedSingleLinePassStatement(self):
     src=trimLines("""
     class MyClass:
         def myMethod(self):
             pass
     """)
     sourcenode = createAST(src)
     em = ExtractMethod(sourcenode, coords(3, 8),
                          coords(3, 12), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(len(em.extractedLines), 1)
     self.assertEqual(em.extractedLines[0], "pass\n")
Esempio n. 4
0
 def test_getsHighlightedSubstringOfLine(self):
     src = trimLines("""
     class MyClass:
         def myMethod(self):
             if a == 3:
                 pass
     """)
     region = trimLines("""
     a == 3
     """)
     sourcenode = writeSourceAndCreateNode(src)
     em = ExtractMethod(sourcenode, coords(3, 11), coords(3, 17), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(em.extractedLines, region.splitlines(1))
Esempio n. 5
0
 def test_getsMultiLineRegionWhenJustRegionIsHighlighted(self):
     src = trimLines("""
     class MyClass:
         def myMethod(self):
             print 'hello'
             pass
     """)
     region = trimLines("""
     print 'hello'
     pass
     """)
     sourcenode = writeSourceAndCreateNode(src)
     em = ExtractMethod(sourcenode, coords(3, 8), coords(4, 12), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(em.extractedLines, region.splitlines(1))
Esempio n. 6
0
 def test_getsHighlightedSubstringOfLine(self):
     src=trimLines("""
     class MyClass:
         def myMethod(self):
             if a == 3:
                 pass
     """)
     region=trimLines("""
     a == 3
     """)
     sourcenode = writeSourceAndCreateNode(src)
     em = ExtractMethod(sourcenode, coords(3, 11),
                          coords(3, 17), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(em.extractedLines, region.splitlines(1))
Esempio n. 7
0
 def test_getsMultiLineRegionWhenJustRegionIsHighlighted(self):
     src=trimLines("""
     class MyClass:
         def myMethod(self):
             print 'hello'
             pass
     """)
     region=trimLines("""
     print 'hello'
     pass
     """)
     sourcenode = writeSourceAndCreateNode(src)
     em = ExtractMethod(sourcenode, coords(3, 8),
                          coords(4, 12), "foobah")
     em.getRegionToBuffer()
     self.assertEqual(em.extractedLines, region.splitlines(1))
Esempio n. 8
0
    def test_getsMultiLineRegionWhenRegionLinesAreHighlighted(self):
        src=trimLines("""
        class MyClass:
            def myMethod(self):
                print 'hello'
                pass

        """)
        region=trimLines("""
        print 'hello'
        pass
        """)
        sourcenode = createAST(src)
        em = ExtractMethod(sourcenode, coords(3, 0),
                             coords(5, 0), "foobah")
        em.getRegionToBuffer()
        self.assertEqual(em.extractedLines, region.splitlines(1))