def testBasicCompare(self): expected_string = 'a < b' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.Compare(create_node.Name('a'), create_node.Lt(), create_node.Name('b')) self.assertNodesEqual(expected_node, test_node)
def testBasicSetComprehensionWithIfs(self): expected_string = '{a for a in b if c < d}' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.SetComp('a', 'a', 'b', create_node.Compare('c', '<', 'd')) self.assertNodesEqual(expected_node, test_node)
def testBasicGeneratorExpWithIfs(self): expected_string = '(a for a in b if c < d)' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.GeneratorExp( 'a', 'a', 'b', create_node.Compare('c', '<', 'd')) self.assertNodesEqual(expected_node, test_node)
def testBasicDictComprehensionWithIfs(self): expected_string = '{a: b for c in d if e < f}' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.DictComp('a', 'b', 'c', 'd', create_node.Compare('e', '<', 'f')) self.assertNodesEqual(expected_node, test_node)
def testNotIn(self): expected_string = 'a not in b' expected_node = GetNodeFromInput(expected_string).value test_node = create_node.Compare(create_node.Name('a'), 'not in', create_node.Name('b')) self.assertNodesEqual(expected_node, test_node)