summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_dialect.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-04-11 23:19:16 +0200
committerFederico Caselli <cfederico87@gmail.com>2022-04-13 22:29:55 +0200
commitc154ed5e047113ce6763cc5a26741f6a5022eb1d (patch)
treec295a93f303e920b7c647f48fbe53de77146a4db /test/dialect/postgresql/test_dialect.py
parentfd052732604a0d03167978215f0077e60b75851d (diff)
downloadsqlalchemy-c154ed5e047113ce6763cc5a26741f6a5022eb1d.tar.gz
Fix psycopg2 pre_ping with autocommit
Fixed an issue what would cause autocommit mode to be reset when using pre_ping in conjunction engine level autocommit on the psycopg2 driver. Fixes: #7930 Change-Id: I4cccaf1b7f8cbacd853689458080784114fcc390
Diffstat (limited to 'test/dialect/postgresql/test_dialect.py')
-rw-r--r--test/dialect/postgresql/test_dialect.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index fb3a522fc..0093eb5ba 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -1068,6 +1068,23 @@ class MiscBackendTest(
dbapi_conn.rollback()
eq_(val, "off")
+ @testing.combinations((True,), (False,), argnames="autocommit")
+ def test_autocommit_pre_ping(self, testing_engine, autocommit):
+ engine = testing_engine(
+ options={
+ "isolation_level": "AUTOCOMMIT"
+ if autocommit
+ else "SERIALIZABLE",
+ "pool_pre_ping": True,
+ }
+ )
+ for i in range(4):
+ with engine.connect() as conn:
+ conn.execute(text("select 1")).scalar()
+
+ dbapi_conn = conn.connection.dbapi_connection
+ eq_(dbapi_conn.autocommit, autocommit)
+
def test_deferrable_flag_engine(self):
engine = engines.testing_engine(
options={