I'm using Django 1.7.7 with python 2.7.6 and Postgres as database and I had a problem with a TransactionTestCase
. In my migrations I had two datamigrations and I wanted them to be available during the tests, so I added serialized_rollback = True
to my test case (https://docs.djangoproject.com/en/1.7/topics/testing/overview/#test-case-serialized-rollback).
The first test of the test cases was ok, but then django was complaining with an IntegrityError
:
IntegrityError: duplicate key value violates unique constraint "django_content_type_app_label_6032a1f08b99c274_uniq"
DETAIL: Key (app_label, model)=(admin, logentry) already exists.
I managed to run the tests and to avoid this error by adding the following to my settings (https://docs.djangoproject.com/en/1.7/ref/settings/#std:setting-TEST_NON_SERIALIZED_APPS):
TEST_NON_SERIALIZED_APPS = ['django.contrib.contenttypes',
'django.contrib.auth']
But I would like to know why is this needed? Is this a bug in the rollback or is this a problem on my side?