Commits

zjes  committed 0fe046e

Fix tests for lambda and slices

  • Participants
  • Parent commits 65846d1

Comments (0)

Files changed (3)

File rope/base/builtins.py

 
     def _list_get(self, context):
         if self.holding is not None:
+            args = context.get_arguments(['self', 'key'])
+            if len(args) > 1 and args[1] is not None \
+                and args[1].get_type() == builtins['slice'].get_object():
+                return get_list(self.holding)
             return self.holding
         return context.get_per_name()
 
         return  'lambda'
 
     def get_param_names(self, special_args=True):
-        result = [node.id for node in self.arguments.args
-                  if isinstance(node, ast.Name)]
+        result = [node.arg for node in self.arguments.args
+                  if isinstance(node, ast.arg)]
         if self.arguments.vararg:
             result.append('*' + self.arguments.vararg)
         if self.arguments.kwarg:

File rope/base/evaluate.py

         return primary, pyobject
 
     def _Subscript(self, node):
-        self._call_function(node.value, '__getitem__',
+        if isinstance(node.slice, ast.Index):
+            self._call_function(node.value, '__getitem__',
+                                [node.slice.value])
+        elif isinstance(node.slice, ast.Slice):
+            self._call_function(node.value, '__getitem__', 
                                 [node.slice])
 
     def _Slice(self, node):

File ropetest/builtinstest.py

     def tearDown(self):
         testutils.remove_project(self.project)
         super(BuiltinTypesTest, self).tearDown()
-
+    
     def test_simple_case(self):
         self.mod.write('l = []\n')
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
         self.assertEquals(c_class, a_var.get_type())
-
+    
     def test_get_items_from_slices(self):
         self.mod.write('class C(object):\n    pass\nl = [C()]\na_var = l[:].pop()\n')
         pymod = self.pycore.resource_to_pyobject(self.mod)
         c_class = pymod['C'].get_object()
         a_var = pymod['a_var'].get_object()
         self.assertEquals(c_class, a_var.get_type())
-
     def test_simple_for_loops(self):
         self.mod.write('class C(object):\n    pass\nl = [C()]\n'
                        'for c in l:\n    a_var = c\n')
         pymod = self.pycore.resource_to_pyobject(self.mod)
         l_var = pymod['l'].get_object()
         self.assertTrue(l_var.get_name() is not None)
-        print(l_var.get_param_names())
         self.assertEquals(len(l_var.get_param_names()), 4)
         self.assertEquals((pymod, 1),
                           pymod['l'].get_definition_location())
         self.mod.write(src)
         self.project.pycore.analyze_module(self.mod)
 
-
 class BuiltinModulesTest(unittest.TestCase):
 
     def setUp(self):