From: jazzthief Date: Wed, 18 Jan 2023 14:46:36 +0000 (+0100) Subject: Add all current operators to precedence test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf998594b8df1d04af7e427c851553d1c8099e83;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add all current operators to precedence test --- diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index f80be34463..a1e5875e64 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -1768,13 +1768,25 @@ class OperatorPrecedenceTest(fixtures.TestBase, testing.AssertsCompiledSQL): self.assert_compile(op2, "mytable.myid hoho :myid_1 lala :param_1") self.assert_compile(op3, "(mytable.myid hoho :myid_1) lala :param_1") - def test_bitwise_xor_precedence(self): - op1 = self.table1.c.myid.bitwise_xor - op2 = op1(5).op("lala", precedence=6)(4) - op3 = op1(5).op("lala", precedence=8)(4) + @testing.combinations( + ("xor", operators.bitwise_xor_op, "^"), + ("or", operators.bitwise_or_op, "|"), + ("and", operators.bitwise_and_op, "&"), + ("lshift", operators.bitwise_lshift_op, "<<"), + ("rshift", operators.bitwise_rshift_op, ">>"), + id_="iaa", + ) + def test_bitwise_op_precedence(self, py_op, sql_op): + c = self.table1.c.myid + op1 = py_op(c, 5).op("lala", precedence=6)(4) + op2 = py_op(c, 5).op("lala", precedence=8)(4) - self.assert_compile(op2, "mytable.myid ^ :myid_1 lala :param_1") - self.assert_compile(op3, "(mytable.myid ^ :myid_1) lala :param_1") + self.assert_compile( + op1, f"mytable.myid {sql_op} :myid_1 lala :param_1" + ) + self.assert_compile( + op2, f"(mytable.myid {sql_op} :myid_1) lala :param_1" + ) def test_is_eq_precedence_flat(self): self.assert_compile(