diff options
Diffstat (limited to 'test/engine/test_execute.py')
-rw-r--r-- | test/engine/test_execute.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index a23f8d05a..85b03e0e9 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -1,4 +1,5 @@ -from test.lib.testing import eq_, assert_raises, assert_raises_message, config +from test.lib.testing import eq_, assert_raises, assert_raises_message, \ + config, is_ import re from test.lib.util import picklers from sqlalchemy.interfaces import ConnectionProxy @@ -1253,6 +1254,33 @@ class EngineEventsTest(fixtures.TestBase): canary, ['execute', 'cursor_execute'] ) + @testing.requires.sequences + @testing.provide_metadata + def test_cursor_execute(self): + canary = [] + def tracker(name): + def go(conn, cursor, statement, parameters, context, executemany): + canary.append((statement, context)) + return go + engine = engines.testing_engine() + + + t = Table('t', self.metadata, + Column('x', Integer, Sequence('t_id_seq'), primary_key=True), + implicit_returning=False + ) + self.metadata.create_all(engine) + with engine.begin() as conn: + event.listen(conn, 'before_cursor_execute', tracker('cursor_execute')) + conn.execute(t.insert()) + # we see the sequence pre-executed in the first call + assert "t_id_seq" in canary[0][0] + assert "INSERT" in canary[1][0] + # same context + is_( + canary[0][1], canary[1][1] + ) + def test_transactional(self): canary = [] def tracker(name): |