def testCallWithStarargsNode(self):
     expected_string = 'a(*[b])'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a',
                                  starargs=create_node.List(
                                      create_node.Name('b')))
     self.assertNodesEqual(expected_node, test_node)
 def testCallWithKwargs(self):
     expected_string = 'a(b="c")'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a',
                                  keys=('b', ),
                                  values=(create_node.Str('c'), ))
     self.assertNodesEqual(expected_node, test_node)
 def testDecoratorList(self):
     expected_string = '@dec\n@dec2()\nclass TestClass():\n  pass\n'
     expected_node = GetNodeFromInput(expected_string)
     test_node = create_node.ClassDef(
         'TestClass',
         decorator_list=[create_node.Name('dec'),
                         create_node.Call('dec2')])
     self.assertNodesEqual(expected_node, test_node)
 def testCallWithKwargsNode(self):
     expected_string = 'a(**{b:c})'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a',
                                  kwargs=create_node.Dict(
                                      keys=(create_node.Name('b'), ),
                                      values=(create_node.Name('c'), )))
     self.assertNodesEqual(expected_node, test_node)
    def testDecoratorList(self):
        expected_string = """@decorator
@other_decorator(arg)
def testFunc(**kwargs):
  pass"""
        expected_node = GetNodeFromInput(expected_string)
        test_node = create_node.FunctionDef('testFunc',
                                            kwarg_name='kwargs',
                                            decorator_list=[
                                                create_node.Name('decorator'),
                                                create_node.Call(
                                                    'other_decorator',
                                                    args=['arg'])
                                            ])
        self.assertNodesEqual(expected_node, test_node)
 def testCallWithKwargsString(self):
     expected_string = 'a(**b)'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a', kwargs='b')
     self.assertNodesEqual(expected_node, test_node)
 def testCallWithArgs(self):
     expected_string = 'a(b)'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a', args=('b'))
     self.assertNodesEqual(expected_node, test_node)
 def testCallWithAttributeNode(self):
     expected_string = 'a.b()'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call(create_node.VarReference('a', 'b'))
     self.assertNodesEqual(expected_node, test_node)
 def testCallWithDotSeparatedCaller(self):
     expected_string = 'a.b()'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a.b')
     self.assertNodesEqual(expected_node, test_node)
 def testCallWithSimpleCaller(self):
     expected_string = 'a()'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a')
     self.assertNodesEqual(expected_node, test_node)