Ticket #16818: 16818_test.diff

File 16818_test.diff, 1.6 KB (added by Preston Holmes, 13 years ago)

regression test

  • tests/regressiontests/transactions_regress/models.py

    diff --git a/tests/regressiontests/transactions_regress/models.py b/tests/regressiontests/transactions_regress/models.py
    index 54e6f4f..e8bca8a 100644
    a b from django.db import models  
    22
    33class Mod(models.Model):
    44    fld = models.IntegerField()
     5
     6class M2mA(models.Model):
     7    others = models.ManyToManyField('M2mB')
     8
     9class M2mB(models.Model):
     10    fld = models.IntegerField()
  • tests/regressiontests/transactions_regress/tests.py

    diff --git a/tests/regressiontests/transactions_regress/tests.py b/tests/regressiontests/transactions_regress/tests.py
    index 26ef416..2195fae 100644
    a b from django.db import connection, transaction  
    55from django.db.transaction import commit_on_success, commit_manually, TransactionManagementError
    66from django.test import TransactionTestCase, skipUnlessDBFeature
    77
    8 from .models import Mod
     8from .models import Mod, M2mA, M2mB
    99
    1010
    1111class TestTransactionClosing(TransactionTestCase):
    class TestTransactionClosing(TransactionTestCase):  
    164164            _ = User.objects.all()[0]
    165165        except:
    166166            self.fail("A transaction consisting of a failed operation was not closed.")
     167
     168class TestManyToManyAddTransaction(TransactionTestCase):
     169    def test_manyrelated_add_commit(self):
     170        """test for 16818"""
     171        a = M2mA.objects.create()
     172        b = M2mB.objects.create(fld=10)
     173        a.others.add(b)
     174        transaction.rollback()
     175        self.assertQuerysetEqual(a.others.all(),['<M2mB: M2mB object>'])
Back to Top