#28895: serialized_rollback = True causes an IntgrityError in LiveServerTestCase
-------------------------------------+-------------------------------------
               Reporter:  Lyra2108   |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Testing    |        Version:  1.8
  framework                          |
               Severity:  Normal     |       Keywords:  LiveServerTestCase
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Hey,

 the project I am working on creates a set of required objects e.g.
 Groups,... within the  database migrations. I would like this data also do
 be present, when I use LiveServerTestCases. But if I run the simple
 example below the 2nd test fails while the first is successful.
 If serialized_rollback = False, the tests fails like expected with a
 "DoesNotExist: Group matching query does not exist." exception.
 But if it is set to True, the exception changes to an integrity exception:
 {{{
 IntegrityError: duplicate key value violates unique constraint
 "django_content_type_app_label_45f3b1d93ec8c61c_uniq"
 DETAIL:  Key (app_label, model)=(contenttypes, contenttype) already
 exists.
 }}}

 Testcase:
 {{{
 from django.conf import settings
 from django.contrib.auth.models import Group
 from django.contrib.staticfiles.testing import StaticLiveServerTestCase


 class Test(StaticLiveServerTestCase):
     serialized_rollback = True

     @classmethod
     def setUpClass(cls):
         super(Test, cls).setUpClass()

     @classmethod
     def tearDownClass(cls):
         super(Test, cls).tearDownClass()

     def test_abc(self):
         group = Group.objects.get(name='groupname')
         assert group

     def test_def(self):
         group = Group.objects.get(name='groupname')
         assert group
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28895>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.d8931e9b66aefc2df7b5be0c0959d505%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to