def test_getsTabwidthForFunctionAtRootScope(self): src = trimLines(""" def myFn(self): pass """) sourcenode = writeSourceAndCreateNode(src) em = ExtractMethod(sourcenode, coords(2, 0), coords(2, 9), "foobah") self.assertEqual(em.getTabwidthOfParentFunction(), 0)
def test_getsTabwidthForFunctionAtRootScope(self): src=trimLines(""" def myFn(self): pass """) sourcenode = writeSourceAndCreateNode(src) em = ExtractMethod(sourcenode, coords(2, 0), coords(2, 9), "foobah") self.assertEqual(em.getTabwidthOfParentFunction(), 0)
def test_getsTabwidthForSimpleMethod(self): src = trimLines(""" class MyClass: def myMethod(self): pass """) sourcenode = writeSourceAndCreateNode(src) em = ExtractMethod(sourcenode, coords(3, 11), coords(3, 17), "foobah") self.assertEqual(em.getTabwidthOfParentFunction(), 4)
def test_getsTabwidthForSimpleMethod(self): src=trimLines(""" class MyClass: def myMethod(self): pass """) sourcenode = writeSourceAndCreateNode(src) em = ExtractMethod(sourcenode, coords(3, 11), coords(3, 17), "foobah") self.assertEqual(em.getTabwidthOfParentFunction(), 4)
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")
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")
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")
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))
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))
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))
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))
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))