Merge pull request #1127 from rafiss/iso-level-finally-block

Handle failure in setup of IsolationLevelsTestCase
This commit is contained in:
Daniele Varrazzo 2020-07-08 20:35:01 +01:00 committed by GitHub
commit cecff195fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -567,9 +567,11 @@ class IsolationLevelsTestCase(ConnectingTestCase):
cur.execute("drop table isolevel;") cur.execute("drop table isolevel;")
except psycopg2.ProgrammingError: except psycopg2.ProgrammingError:
conn.rollback() conn.rollback()
cur.execute("create table isolevel (id integer);") try:
conn.commit() cur.execute("create table isolevel (id integer);")
conn.close() conn.commit()
finally:
conn.close()
def test_isolation_level(self): def test_isolation_level(self):
conn = self.connect() conn = self.connect()