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.
* 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>