Commits

Anonymous committed 3b6aa27

added tests for dos line-endings and multi-byte chars when renaming

Comments (0)

Files changed (1)

ropetest/refactor/renametest.py

         testmod = testutils.create_module(self.project, 'testmod')
         testmod.write(source_code)
         changes = Rename(self.project, testmod, offset).\
-                  get_changes(new_name, in_file=True)
+            get_changes(new_name, in_file=True)
         self.project.do(changes)
         return testmod.read()
 
         refactored = self._local_rename(code, code.index('a_var') + 1, 'new_var')
         self.assertEquals(code.replace('a_var', 'new_var', 2), refactored)
 
+    def test_dos_line_ending_and_renaming(self):
+        code = '\r\na = 1\r\n\r\nprint(2 + a + 2)\r\n'
+        offset = code.replace('\r\n', '\n').rindex('a')
+        refactored = self._local_rename(code, offset, 'b')
+        self.assertEquals('\nb = 1\n\nprint(2 + b + 2)\n',
+                          refactored.replace('\r\n', '\n'))
+
+    def test_multi_byte_strs_and_renaming(self):
+        s = u'{LATIN SMALL LETTER I WITH DIAERESIS}' * 4
+        code = u'# -*- coding: utf-8 -*-\n# ' + s + \
+                '\na = 1\nprint(2 + a + 2)\n'
+        refactored = self._local_rename(code, code.rindex('a'), 'b')
+        self.assertEquals(u'# -*- coding: utf-8 -*-\n# ' + s +
+                          '\nb = 1\nprint(2 + b + 2)\n', refactored)
+
 
 class ChangeOccurrencesTest(unittest.TestCase):