コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
    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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
 def testCallWithSimpleCaller(self):
     expected_string = 'a()'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.Call('a')
     self.assertNodesEqual(expected_node, test_node)