diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-14 01:18:58 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-14 01:18:58 -0500 |
| commit | 59f0685290b0847ecf83f5a9a64d99931d319bd6 (patch) | |
| tree | 613ae288b5675ace2c3f7414647f537746161432 /test/engine/test_bind.py | |
| parent | 504daf1bc09a9db475ed656c552d9bf7f993d20f (diff) | |
| download | sqlalchemy-59f0685290b0847ecf83f5a9a64d99931d319bd6.tar.gz | |
The :meth:`.Connection.connect` and :meth:`.Connection.contextual_connect`
methods now return a "branched" version so that the :meth:`.Connection.close`
method can be called on the returned connection without affecting the
original. Allows symmetry when using :class:`.Engine` and
:class:`.Connection` objects as context managers.
Diffstat (limited to 'test/engine/test_bind.py')
| -rw-r--r-- | test/engine/test_bind.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/engine/test_bind.py b/test/engine/test_bind.py index 30ee43b3b..f76350fcc 100644 --- a/test/engine/test_bind.py +++ b/test/engine/test_bind.py @@ -1,6 +1,6 @@ """tests the "bind" attribute/argument across schema and SQL, including the deprecated versions of these arguments""" - +from __future__ import with_statement from sqlalchemy.testing import eq_, assert_raises from sqlalchemy import engine, exc from sqlalchemy import MetaData, ThreadLocalMetaData @@ -12,6 +12,29 @@ from sqlalchemy import testing from sqlalchemy.testing import fixtures class BindTest(fixtures.TestBase): + def test_bind_close_engine(self): + e = testing.db + with e.connect() as conn: + assert not conn.closed + assert conn.closed + + with e.contextual_connect() as conn: + assert not conn.closed + assert conn.closed + + def test_bind_close_conn(self): + e = testing.db + conn = e.connect() + with conn.connect() as c2: + assert not c2.closed + assert not conn.closed + assert c2.closed + + with conn.contextual_connect() as c2: + assert not c2.closed + assert not conn.closed + assert c2.closed + def test_create_drop_explicit(self): metadata = MetaData() table = Table('test_table', metadata, |
