rope icon indicating copy to clipboard operation
rope copied to clipboard

[TEST] rename renames keyword args in function calls

Open mcepl opened this issue 12 years ago • 0 comments

hello,

I've written a test for rope that fails when a keyword argument to a function is the same as the name of the variable to be renamed, like this:

a = 10
foo = dict(a=a)

when a is renamed to new_a, the result will look like this:

new_a = 10
foo = dict(new_a=new_a)

This is the test case:

diff -r 1c100ebabc16 ropetest/refactor/renametest.py
--- a/ropetest/refactor/renametest.py   Sat Apr 09 17:20:27 2011 +0200
+++ b/ropetest/refactor/renametest.py   Tue May 10 00:48:39 2011 +0200
@@ -32,6 +32,11 @@
                   get_changes(new_name, **kwds)
         self.project.do(changes)

+    def test_local_variable_but_not_parameter(self):
+        code = "a = 10\nfoo = dict(a=a)"
+        refactored = self._local_rename(code, 1, "new_a")
+        self.assertEquals(refactored, "new_a = 10\nfoo = dict(a=new_a)")
+
     def test_simple_global_variable_renaming(self):
         refactored = self._local_rename('a_var = 20\n', 2, 'new_var')
         self.assertEquals('new_var = 20\n', refactored)

Thank you for this most excellent tool :)

  • Timo

mcepl avatar Nov 30 '13 23:11 mcepl