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 testDictRaisesErrorIfNotMatchingLengths(self): with self.assertRaises(ValueError): unused_test_node = create_node.Dict([create_node.Str('a')], [])
def testDictWithNoKeysOrVals(self): expected_string = '{}' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.Dict([], []) self.assertNodesEqual(expected_node, test_node)
def testDictWithNonStringKeys(self): expected_string = '{a: 1}' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.Dict([create_node.Name('a')], [create_node.Num(1)]) self.assertNodesEqual(expected_node, test_node)
def testDictWithStringKeys(self): expected_string = '{"a": "b"}' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.Dict([create_node.Str('a')], [create_node.Str('b')]) self.assertNodesEqual(expected_node, test_node)