diff options
author | Gord Thompson <gord@gordthompson.com> | 2020-02-13 12:14:42 -0700 |
---|---|---|
committer | Gord Thompson <gord@gordthompson.com> | 2020-02-17 10:15:12 -0700 |
commit | 60f627cbd0d769e65353e720548efac9d8ab95d9 (patch) | |
tree | 2370558b27263eeeae1f6731d39d80f2483b18e0 /lib/sqlalchemy/testing/suite/test_insert.py | |
parent | 3c7765b49c0aba253c11f435b2923bb488d15809 (diff) | |
download | sqlalchemy-60f627cbd0d769e65353e720548efac9d8ab95d9.tar.gz |
Replace engine.execute w/ context manager (step1)
First (baby) step at replacing engine.execute
calls in test code with the new preferred way
of executing. MSSQL was targeted because it was
the easiest for me to test locally.
Change-Id: Id2e02f0e39007cbfd28ca6a535115f53c6407015
Diffstat (limited to 'lib/sqlalchemy/testing/suite/test_insert.py')
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_insert.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py index 2cc8761b8..931b0ef65 100644 --- a/lib/sqlalchemy/testing/suite/test_insert.py +++ b/lib/sqlalchemy/testing/suite/test_insert.py @@ -109,7 +109,8 @@ class InsertBehaviorTest(fixtures.TablesTest): else: engine = config.db - r = engine.execute(self.tables.autoinc_pk.insert(), data="some data") + with engine.begin() as conn: + r = conn.execute(self.tables.autoinc_pk.insert(), data="some data") assert r._soft_closed assert not r.closed assert r.is_insert @@ -278,9 +279,10 @@ class ReturningTest(fixtures.TablesTest): def test_explicit_returning_pk_autocommit(self): engine = config.db table = self.tables.autoinc_pk - r = engine.execute( - table.insert().returning(table.c.id), data="some data" - ) + with engine.begin() as conn: + r = conn.execute( + table.insert().returning(table.c.id), data="some data" + ) pk = r.first()[0] fetched_pk = config.db.scalar(select([table.c.id])) eq_(fetched_pk, pk) |