def test_equality_rewrite_literals(self):
        "Test an equality rewrite with different literals"
        l = ast.Literal('foo')
        v = ast.Literal('bar')
        v2 = ast.Literal('baz')
        cmp1 = ast.CompareOperator('=', l, v)
        cmp2 = ast.CompareOperator('=', l, v2)
        or1 = ast.LogicalOperator('or', cmp1, cmp2)

        # Rewrite foo = bar as True
        # Left should be True, right should be unchanged
        name = merge.node_name(cmp1, True)
        r = compare.equality_rewrite(ast.dup(or1), name, cmp1, True)

        assert isinstance(r.left, ast.Constant)
        assert r.left.value == True
        assert ASTPattern(cmp2).matches(r.right)

        # Rewrite foo = bar as False
        # Left should be False, right should be same
        name = merge.node_name(cmp1, True)
        r = compare.equality_rewrite(ast.dup(or1), name, cmp1, False)

        assert isinstance(r.left, ast.Constant)
        assert r.left.value == False
        assert ASTPattern(cmp2).matches(r.right)

        # Rewrite foo = baz as True
        # Left should be same, right should be True
        name = merge.node_name(cmp2, True)
        r = compare.equality_rewrite(ast.dup(or1), name, cmp2, True)

        assert ASTPattern(cmp1).matches(r.left)
        assert isinstance(r.right, ast.Constant)
        assert r.right.value == True

        # Rewrite foo = baz as False
        # Left should be same, right should be False
        name = merge.node_name(cmp2, True)
        r = compare.equality_rewrite(ast.dup(or1), name, cmp2, False)

        assert ASTPattern(cmp1).matches(r.left)
        assert isinstance(r.right, ast.Constant)
        assert r.right.value == False
dataset/ETHPy150Open armon/pypred/tests/unit/test_compare.py/TestCompare.test_equality_rewrite_literals/original