Ticket #29575: 29575.diff

File 29575.diff, 959 bytes (added by Claude Paroz, 6 years ago)

IntegrityError test

  • tests/backends/tests.py

    diff --git a/tests/backends/tests.py b/tests/backends/tests.py
    index 6e6868edfb..cec4db1edb 100644
    a b from django.test import (  
    1919)
    2020
    2121from .models import (
    22     Article, Object, ObjectReference, Person, Post, RawData, Reporter,
     22    Article, Author, Object, ObjectReference, Person, Post, RawData, Reporter,
    2323    ReporterProxy, SchoolClass, Square,
    2424    VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ,
    2525)
    class DBConstraintTestCase(TestCase):  
    778778        intermediary_model.objects.create(from_object_id=obj.id, to_object_id=12345)
    779779        self.assertEqual(obj.related_objects.count(), 1)
    780780        self.assertEqual(intermediary_model.objects.count(), 2)
     781
     782    def test_field_unique_integrity_error(self):
     783        Author.objects.create(name='Tolkien')
     784        with self.assertRaises(IntegrityError):
     785            Author.objects.create(name='Tolkien')
Back to Top