diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-10 19:38:22 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-10 19:38:22 -0400 |
| commit | 5280f26d45f6d79013d2da3bd5e0fe4a88117b20 (patch) | |
| tree | b58a4623060d7caf0ac509d0655fe1a09661e44c /test/engine/test_execute.py | |
| parent | 3269b73ff7a12303aadcaed0246d401ec649fa94 (diff) | |
| download | sqlalchemy-5280f26d45f6d79013d2da3bd5e0fe4a88117b20.tar.gz | |
- [feature] Added new connection event
dbapi_error(). Is called for all DBAPI-level
errors passing the original DBAPI exception
before SQLAlchemy modifies the state
of the cursor.
Diffstat (limited to 'test/engine/test_execute.py')
| -rw-r--r-- | test/engine/test_execute.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 146725f45..6bdbf4227 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -984,6 +984,23 @@ class EngineEventsTest(fixtures.TestBase): e1.execute(select([1]).compile(dialect=e1.dialect)) e1._execute_compiled(select([1]).compile(dialect=e1.dialect), [], {}) + def test_exception_event(self): + engine = engines.testing_engine() + canary = [] + + @event.listens_for(engine, 'dbapi_error') + def err(conn, cursor, stmt, parameters, context, exception): + canary.append((stmt, parameters, exception)) + + conn = engine.connect() + try: + conn.execute("SELECT FOO FROM I_DONT_EXIST") + assert False + except tsa.exc.DBAPIError, e: + assert canary[0][2] is e.orig + assert canary[0][0] == "SELECT FOO FROM I_DONT_EXIST" + + @testing.fails_on('firebird', 'Data type unknown') def test_execute_events(self): |
