def test_canonical_non_literal(self): "Test canonicalization, literals on left" v = ast.Number(42) l = ast.Literal('foo') cmp = ast.CompareOperator('=', v, l) compare.canonicalize(cmp) assert cmp.left is l assert cmp.right is v
def test_canonical_literal_order(self): "Test canonicalization, literals on left" l = ast.Literal('foo') r = ast.Literal('zip') cmp = ast.CompareOperator('>', r, l) compare.canonicalize(cmp) assert cmp.left is l assert cmp.right is r assert cmp.type == "<"
def test_canonical_non_static(self): "Test canonicalization, literals on left" static = ast.Literal("'string'") static.static = True static.static_val = 'string' l = ast.Literal('foo') cmp = ast.CompareOperator('=', static, l) compare.canonicalize(cmp) assert cmp.left is l assert cmp.right is static
def test_canonical_static_order(self): "Test canonicalization, static ordering" static = ast.Literal("'string'") static.static = True static.static_val = 'string' static2 = ast.Literal("'foo'") static2.static = True static2.static_val = 'foo' cmp = ast.CompareOperator('<', static, static2) compare.canonicalize(cmp) assert cmp.left is static2 assert cmp.right is static assert cmp.type == ">"