'Make sure that under commit_on_success, a transaction is rolled back even if
the first database-modifying operation fails.
This is prompted by http://code.djangoproject.com/ticket/6669 (and based on sample
code posted there to exemplify the problem): Before Django 1.3,
transactions were only marked "dirty" by the save() function after it successfully
wrote the object to the database.'

def test_failing_query_transaction_closed(self):

    from django.contrib.auth.models import User
    @transaction.commit_on_success
    def create_system_user():
        'Create    a    user    in    a    transaction'
        user = User.objects.create_user(username='system', password='iamr00t', email='root@SITENAME.com')
        Mod.objects.create(fld=user.id)
    create_system_user()
    try:
        create_system_user()
    except:
        pass
    else:
        raise ImproperlyConfigured('Unique    constraint    not    enforced    on    django.contrib.auth.models.User')
    try:
        _ = User.objects.all()[0]
    except:
        self.fail('A    transaction    consisting    of    a    failed    operation    was    not    closed.')
