Exemple #1
0
 def extractLocalVariable(self, filename_path, begin_line, begin_col,
                          end_line, end_col, variablename):
     filename_path = self.normalizeFilename(filename_path)
     extractVariable.extractLocalVariable(filename_path,
                                          coords(begin_line, begin_col),
                                          coords(end_line, end_col),
                                          variablename)
Exemple #2
0
 def extractLocalVariable(self,filename_path, begin_line, begin_col,
                          end_line, end_col, variablename):
     filename_path = self.normalizeFilename(filename_path)
     extractVariable.extractLocalVariable(filename_path,
                                          coords(begin_line, begin_col),
                                          coords(end_line, end_col),
                                          variablename)
 def test_worksIfCoordsTheWrongWayRound(self):
     srcBefore=trimLines("""
     def foo():
         print 3 + 2
     """)
     srcAfter=trimLines("""
     def foo():
         a = 3 + 2
         print a
     """)
     writeFile(tmpfile,srcBefore)
     extractLocalVariable(tmpfile,coords(2,15),coords(2,10),'a')
     self.assertEqual(srcAfter,getQueuedFileContents(tmpfile))
 def test_worksOnSimpleCase(self):
     srcBefore=trimLines("""
     def foo():
         print 3 + 2
     """)
     srcAfter=trimLines("""
     def foo():
         a = 3 + 2
         print a
     """)
     sourcenode = createAST(srcBefore)
     extractLocalVariable(tmpfile,coords(2,10),coords(2,15),'a')
     self.assertEqual(sourcenode.getSource(),srcAfter)
Exemple #5
0
 def test_worksIfCoordsTheWrongWayRound(self):
     srcBefore = trimLines("""
     def foo():
         print 3 + 2
     """)
     srcAfter = trimLines("""
     def foo():
         a = 3 + 2
         print a
     """)
     writeFile(tmpfile, srcBefore)
     extractLocalVariable(tmpfile, coords(2, 15), coords(2, 10), 'a')
     self.assertEqual(srcAfter, getQueuedFileContents(tmpfile))
 def test_worksOnSimpleCase(self):
     srcBefore = trimLines("""
     def foo():
         print 3 + 2
     """)
     srcAfter = trimLines("""
     def foo():
         a = 3 + 2
         print a
     """)
     sourcenode = createAST(srcBefore)
     extractLocalVariable(tmpfile, coords(2, 10), coords(2, 15), 'a')
     self.assertEqual(sourcenode.getSource(), srcAfter)