Handle failure in setup of ConnectionTwoPhaseTest

Previously, this test had a bug, because if the CREATE TABLE statement
failed, the setup would fail without committing or rolling back the
active transaction.
This commit is contained in:
Rafi Shamim 2020-05-07 18:26:24 -04:00
parent 14355e9c69
commit f935476b3f

View File

@ -913,8 +913,10 @@ class ConnectionTwoPhaseTests(ConnectingTestCase):
cur.execute("DROP TABLE test_tpc;") cur.execute("DROP TABLE test_tpc;")
except psycopg2.ProgrammingError: except psycopg2.ProgrammingError:
cnn.rollback() cnn.rollback()
try:
cur.execute("CREATE TABLE test_tpc (data text);") cur.execute("CREATE TABLE test_tpc (data text);")
cnn.commit() cnn.commit()
finally:
cnn.close() cnn.close()
def count_xacts(self): def count_xacts(self):