@testing.requires.two_phase_transactions
def test_two_phase_transaction(self, local_connection):
    connection = local_connection
    users = self.tables.users
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=1, user_name='user1')
    transaction.prepare()
    transaction.commit()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=2, user_name='user2')
    transaction.commit()
    transaction.close()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=3, user_name='user3')
    transaction.rollback()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=4, user_name='user4')
    transaction.prepare()
    transaction.rollback()
    transaction.close()
    eq_(connection.execute(select(users.c.user_id).order_by(users.c.user_id)).fetchall(), [(1,), (2,)])
@testing.requires.two_phase_transactions
def test_two_phase_transaction(self, local_connection):
    connection = local_connection
    users = self.tables.users
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=1, user_name='user1')
    transaction.prepare()
    transaction.commit()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=2, user_name='user2')
    transaction.commit()
    transaction.close()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=3, user_name='user3')
    transaction.rollback()
    transaction = connection.begin_twophase()
    connection.execute(users.insert(), user_id=4, user_name='user4')
    transaction.prepare()
    transaction.rollback()
    transaction.close()
    eq_(connection.execute(select(users.c.user_id).order_by(users.c.user_id)).fetchall(), [(1,), (2,)])