Пример #1
0
 def test_removing_keyword_arg2(self):
     self.mod.write('def a_func(p1, *args, **kwds):\n    pass\na_func(1)\n')
     signature = ChangeSignature(self.project, self.mod,
                                 self.mod.read().index('a_func') + 1)
     signature.remove(2).do()
     self.assertEquals('def a_func(p1, *args):\n    pass\na_func(1)\n',
                       self.mod.read())
Пример #2
0
 def test_removing_arguments_passed_as_keywords(self):
     self.mod.write('def a_func(p1):\n    pass\na_func(p1=1)\n')
     signature = ChangeSignature(self.project, self.mod,
                                 self.mod.read().index('a_func') + 1)
     signature.remove(0).do()
     self.assertEquals('def a_func():\n    pass\na_func()\n',
                       self.mod.read())
Пример #3
0
 def test_removing_arguments_star_args(self):
     self.mod.write('def a_func(p1, *args):\n    pass\na_func(1)\n')
     signature = ChangeSignature(self.project, self.mod,
                                 self.mod.read().index('a_func') + 1)
     signature.remove(1).do()
     self.assertEquals('def a_func(p1):\n    pass\na_func(1)\n',
                       self.mod.read())
Пример #4
0
 def test_removing_arguments_with_multiple_args(self):
     self.mod.write('def a_func(p1, p2):\n    pass\na_func(1, 2)\n')
     signature = ChangeSignature(self.project, self.mod,
                                 self.mod.read().index('a_func') + 1)
     signature.remove(0).do()
     self.assertEquals('def a_func(p2):\n    pass\na_func(2)\n',
                       self.mod.read())
Пример #5
0
 def test_differentiating_class_accesses_from_instance_accesses(self):
     self.mod.write(
         'class A(object):\n    def a_func(self, param):\n        pass\n'
         'a_var = A()\nA.a_func(a_var, param=1)')
     signature = ChangeSignature(self.project, self.mod,
                                 self.mod.read().index('a_func') + 1)
     signature.remove(1).do()
     self.assertEquals(
         'class A(object):\n    def a_func(self):\n        pass\n'
         'a_var = A()\nA.a_func(a_var)', self.mod.read())