]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
moved and renamed test 5446/head
authorRamonWill <ramonwilliams@hotmail.co.uk>
Sun, 19 Jul 2020 20:13:30 +0000 (21:13 +0100)
committerRamonWill <ramonwilliams@hotmail.co.uk>
Sun, 19 Jul 2020 20:13:30 +0000 (21:13 +0100)
test/orm/test_events.py
test/orm/test_query.py

index b68e0d2e652232f638e42bdadcf17e4f96e10b0e..12458165571a0775c1c2fe593a5e023d5f4d5c5c 100644 (file)
@@ -2602,6 +2602,25 @@ class QueryEventsTest(
             )
         )
 
+    def test_before_compile_execution_options(self):
+        User = self.classes.User
+
+        @event.listens_for(query.Query, "before_compile", retval=True)
+        def _before_compile(query):
+            return query.execution_options(my_option=True)
+
+        opts = {}
+
+        @event.listens_for(testing.db, "before_cursor_execute")
+        def _before_cursor_execute(
+            conn, cursor, statement, parameters, context, executemany
+        ):
+            opts.update(context.execution_options)
+
+        sess = create_session(bind=testing.db, autocommit=False)
+        sess.query(User).first()
+        eq_(opts["my_option"], True)
+
 
 class RefreshFlushInReturningTest(fixtures.MappedTest):
     """test [ticket:3427].
index 4416c51d0b47ebb354eb2399663d6c0269257ffe..7ef2a455ea55830a7278381f40f750e9ef032d35 100644 (file)
@@ -12,7 +12,6 @@ from sqlalchemy import collate
 from sqlalchemy import column
 from sqlalchemy import desc
 from sqlalchemy import distinct
-from sqlalchemy import event
 from sqlalchemy import exc as sa_exc
 from sqlalchemy import exists
 from sqlalchemy import ForeignKey
@@ -5821,25 +5820,6 @@ class ExecutionOptionsTest(QueryTest):
         q1 = sess.query(User).execution_options(**execution_options)
         q1.all()
 
-    def test_options_before_compile(self):
-        User = self.classes.User
-
-        @event.listens_for(Query, "before_compile", retval=True)
-        def _before_compile(query):
-            return query.execution_options(my_option=True)
-
-        opts = {}
-
-        @event.listens_for(testing.db, "before_cursor_execute")
-        def _before_cursor_execute(
-            conn, cursor, statement, parameters, context, executemany
-        ):
-            opts.update(context.execution_options)
-
-        sess = create_session(bind=testing.db, autocommit=False)
-        sess.query(User).first()
-        eq_(opts["my_option"], True)
-
 
 class BooleanEvalTest(fixtures.TestBase, testing.AssertsCompiledSQL):
     """test standalone booleans being wrapped in an AsBoolean, as well