コード例 #1
0
 def testDeleteInvalid(self):
     expected_string = 'del [a, b]'
     expected_node = GetNodeFromInput(expected_string).targets[0]
     test_node = create_node.List(create_node.Name('a'),
                                  create_node.Name('b'),
                                  ctx_type=create_node.CtxEnum.DEL)
     self.assertNodesEqual(expected_node, test_node)
コード例 #2
0
 def testListStore(self):
     expected_string = '[a, b] = ["c", "d"]'
     expected_node = GetNodeFromInput(expected_string).targets[0]
     test_node = create_node.List(create_node.Name('a'),
                                  create_node.Name('b'),
                                  ctx_type=create_node.CtxEnum.STORE)
     self.assertNodesEqual(expected_node, test_node)
コード例 #3
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)
コード例 #4
0
 def testListOverridesInnerCtx(self):
     expected_string = 'a = [b, c]'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.List(
         create_node.Name('b', ctx_type=create_node.CtxEnum.DEL),
         create_node.Name('c', ctx_type=create_node.CtxEnum.STORE),
         ctx_type=create_node.CtxEnum.LOAD)
     self.assertNodesEqual(expected_node, test_node)
コード例 #5
0
 def testListLoad(self):
     expected_string = 'a = ["b"]'
     expected_node = GetNodeFromInput(expected_string).value
     test_node = create_node.List(create_node.Str('b'),
                                  ctx_type=create_node.CtxEnum.LOAD)
     self.assertNodesEqual(expected_node, test_node)