#30751: Old bug: IntegrityError with TransactionTestCase and
serialized_rollback=True
-------------------------------------+-------------------------------------
               Reporter:  raywtham   |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Testing    |        Version:  2.2
  framework                          |       Keywords:
               Severity:  Normal     |  APITransactionTestCase
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I experienced the same issue in #23727 (which is marked as fixed)

 {{{
 Traceback (most recent call last):
   File "/usr/local/lib/python3.6/site-
 packages/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
 psycopg2.errors.UniqueViolation: duplicate key value violates unique
 constraint "django_content_type_app_label_model_76bd3d3b_uniq"
 DETAIL:  Key (app_label, model)=(admin, logentry) already exists.


 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "/usr/local/lib/python3.6/site-packages/django/test/testcases.py",
 line 267, in __call__
     self._pre_setup()
   File "/usr/local/lib/python3.6/site-packages/django/test/testcases.py",
 line 938, in _pre_setup
     self._fixture_setup()
   File "/usr/local/lib/python3.6/site-packages/django/test/testcases.py",
 line 987, in _fixture_setup
     connections[db_name]._test_serialized_contents
   File "/usr/local/lib/python3.6/site-
 packages/django/db/backends/base/creation.py", line 133, in
 deserialize_db_from_string
     obj.save()
   File "/usr/local/lib/python3.6/site-
 packages/django/core/serializers/base.py", line 223, in save
     models.Model.save_base(self.object, using=using, raw=True, **kwargs)
   File "/usr/local/lib/python3.6/site-packages/django/db/models/base.py",
 line 779, in save_base
     force_update, using, update_fields,
   File "/usr/local/lib/python3.6/site-packages/django/db/models/base.py",
 line 870, in _save_table
     result = self._do_insert(cls._base_manager, using, fields, update_pk,
 raw)
   File "/usr/local/lib/python3.6/site-packages/django/db/models/base.py",
 line 908, in _do_insert
     using=using, raw=raw)
   File "/usr/local/lib/python3.6/site-
 packages/django/db/models/manager.py", line 82, in manager_method
     return getattr(self.get_queryset(), name)(*args, **kwargs)
   File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py",
 line 1186, in _insert
     return query.get_compiler(using=using).execute_sql(return_id)
   File "/usr/local/lib/python3.6/site-
 packages/django/db/models/sql/compiler.py", line 1332, in execute_sql
     cursor.execute(sql, params)
   File "/usr/local/lib/python3.6/site-
 packages/django/db/backends/utils.py", line 67, in execute
     return self._execute_with_wrappers(sql, params, many=False,
 executor=self._execute)
   File "/usr/local/lib/python3.6/site-
 packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
     return executor(sql, params, many, context)
   File "/usr/local/lib/python3.6/site-
 packages/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
   File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line
 89, in __exit__
     raise dj_exc_value.with_traceback(traceback) from exc_value
   File "/usr/local/lib/python3.6/site-
 packages/django/db/backends/utils.py", line 84, in _execute
     return self.cursor.execute(sql, params)
 django.db.utils.IntegrityError: duplicate key value violates unique
 constraint "django_content_type_app_label_model_76bd3d3b_uniq"
 DETAIL:  Key (app_label, model)=(admin, logentry) already exists.
 }}}

 I am currently using this as a workaround:
 {{{
 TEST_NON_SERIALIZED_APPS = ['django.contrib.contenttypes',
 'django.contrib.auth']
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30751>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.84c31351d803244a7f6eb664a1e8777d%40djangoproject.com.

Reply via email to