mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 17:34:08 +03:00
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:
parent
14355e9c69
commit
f935476b3f
|
@ -913,9 +913,11 @@ class ConnectionTwoPhaseTests(ConnectingTestCase):
|
|||
cur.execute("DROP TABLE test_tpc;")
|
||||
except psycopg2.ProgrammingError:
|
||||
cnn.rollback()
|
||||
cur.execute("CREATE TABLE test_tpc (data text);")
|
||||
cnn.commit()
|
||||
cnn.close()
|
||||
try:
|
||||
cur.execute("CREATE TABLE test_tpc (data text);")
|
||||
cnn.commit()
|
||||
finally:
|
||||
cnn.close()
|
||||
|
||||
def count_xacts(self):
|
||||
"""Return the number of prepared xacts currently in the test db."""
|
||||
|
|
Loading…
Reference in New Issue
Block a user