Hi,

I'm having a problem using a TransactionTestCase with a sqlite database and 
was hoping someone could tell me where I've gone wrong.

I'm porting a project from Django 1.6 to 1.7 that uses LiveServerTestCase 
with a sqlite test database. I converted all of my initial_data fixtures to 
be proper data migrations. When I did that my live server tests started 
failing until I stumbled upon the serialized_rollback option to 
TransactionTestCase. However now I get the following error instead:


Traceback (most recent call last):
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/test/testcases.py",
 
line 182, in __call__
    self._pre_setup()
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/test/testcases.py",
 
line 754, in _pre_setup
    self._fixture_setup()
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/test/testcases.py",
 
line 797, in _fixture_setup
    connections[db_name]._test_serialized_contents
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/backends/creation.py",
 
line 428, in deserialize_db_from_string
    obj.save()
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/core/serializers/base.py",
 
line 173, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 618, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, 
update_fields)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 699, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, 
raw)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/models/base.py",
 
line 732, in _do_insert
    using=using, raw=raw)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/models/manager.py",
 
line 92, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 921, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
 
line 920, in execute_sql
    cursor.execute(sql, params)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py",
 
line 65, in execute
    return self.cursor.execute(sql, params)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/utils.py", 
line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py",
 
line 65, in execute
    return self.cursor.execute(sql, params)
  File 
"/tmp/djangomigrate/venv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",
 
line 485, in execute
    return Database.Cursor.execute(self, query, params)
IntegrityError: columns app_label, model are not unique


I did some digging and it looks like the django.contrib.contenttypes app 
has a post-migrate script that populates the content type table. However, 
using the serialized_rollback option to refresh my migrated data also 
inserts saved duplicates into the content type table, which results in this 
exception.

I've created a minimal project that demonstrates the problem here: 
https://github.com/tctimmeh/djangomigrate

Is there any way to get my tests working? Any advice would be appreciated.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75968f10-7ffa-4c32-8093-d25999cff83d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to