diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-12 14:38:52 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-12 14:38:52 -0400 |
| commit | 9273cdd6387bdf2182e595bdd5144a1792e9e1a4 (patch) | |
| tree | 9913e1f2c844107064eb653787ba662d9b58a792 /test/engine/test_execute.py | |
| parent | 3d66f727f56426592d70d5cf54bbcb891172b6f0 (diff) | |
| download | sqlalchemy-9273cdd6387bdf2182e595bdd5144a1792e9e1a4.tar.gz | |
- [bug] If conn.begin() fails when calling
"with engine.begin()", the newly acquired
Connection is closed explicitly before
propagating the exception onward normally.
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 6bdbf4227..610f5e42b 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -358,6 +358,23 @@ class ConvenienceExecuteTest(fixtures.TablesTest): testing.run_as_contextmanager(ctx, fn, 5, value=8) self._assert_fn(5, value=8) + def test_transaction_engine_ctx_begin_fails(self): + engine = engines.testing_engine() + class MockConnection(Connection): + closed = False + def begin(self): + raise Exception("boom") + + def close(self): + MockConnection.closed = True + engine._connection_cls = MockConnection + fn = self._trans_fn() + assert_raises( + Exception, + engine.begin + ) + assert MockConnection.closed + def test_transaction_engine_ctx_rollback(self): fn = self._trans_rollback_fn() ctx = testing.db.begin() |
