[Django] #28895: serialized_rollback = True causes an IntgrityError in LiveServerTestCase

6 views
Skip to first unread message

Django

unread,
Dec 5, 2017, 2:54:39 PM12/5/17
to django-...@googlegroups.com
#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.

Django

unread,
Dec 5, 2017, 3:15:45 PM12/5/17
to django-...@googlegroups.com
#28895: serialized_rollback = True causes an IntgrityError in LiveServerTestCase
------------------------------------+--------------------------------------
Reporter: Lyra2108 | Owner: nobody
Type: Bug | Status: closed
Component: Testing framework | Version: 1.8
Severity: Normal | Resolution: duplicate
Keywords: LiveServerTestCase | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #23727. Fixed in Django 1.9+ by
d3fdaf907db6a5be4d0391532d7e65688c19e851. In the future, please try to
verify bugs against the most recent Django release.

--
Ticket URL: <https://code.djangoproject.com/ticket/28895#comment:1>

Reply all
Reply to author
Forward
0 new messages