From: RamonWill Date: Sun, 19 Jul 2020 20:13:30 +0000 (+0100) Subject: moved and renamed test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5446%2Fhead;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git moved and renamed test --- diff --git a/test/orm/test_events.py b/test/orm/test_events.py index b68e0d2e65..1245816557 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -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]. diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 4416c51d0b..7ef2a455ea 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -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