'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.pk)
    create_system_user()
    with self.assertRaises(DatabaseError):
        create_system_user()
    User.objects.all()[0]
