def test_with_interface(self, local_connection):
    connection = local_connection
    users = self.tables.users
    trans = connection.begin()
    connection.execute(users.insert(), user_id=1, user_name='user1')
    connection.execute(users.insert(), user_id=2, user_name='user2')
    try:
        connection.execute(users.insert(), user_id=2, user_name='user2.5')
    except Exception:
        trans.__exit__(*sys.exc_info())
    assert (not trans.is_active)
    self.assert_((connection.exec_driver_sql('select count(*) from users').scalar() == 0))
    trans = connection.begin()
    connection.execute(users.insert(), user_id=1, user_name='user1')
    trans.__exit__(None, None, None)
    assert (not trans.is_active)
    self.assert_((connection.exec_driver_sql('select count(*) from users').scalar() == 1))
def test_with_interface(self, local_connection):
    connection = local_connection
    users = self.tables.users
    trans = connection.begin()
    connection.execute(users.insert(), user_id=1, user_name='user1')
    connection.execute(users.insert(), user_id=2, user_name='user2')
    try:
        connection.execute(users.insert(), user_id=2, user_name='user2.5')
    except Exception:
        trans.__exit__(*sys.exc_info())
    assert (not trans.is_active)
    self.assert_((connection.exec_driver_sql('select count(*) from users').scalar() == 0))
    trans = connection.begin()
    connection.execute(users.insert(), user_id=1, user_name='user1')
    trans.__exit__(None, None, None)
    assert (not trans.is_active)
    self.assert_((connection.exec_driver_sql('select count(*) from users').scalar() == 1))