Well, answer is here: 
https://docs.djangoproject.com/en/1.7/topics/testing/overview/#rollback-emulation
Need to use serialized_rollback = True in TransactionTestCase

Le mercredi 4 mars 2015 18:24:34 UTC+1, sam a écrit :
>
> Hello, 
>
> I have an issue trying to run tests.
> My application use a migration to have default fixtures (created using 
> migrations.RunPython from a migration file). 
> The problem is when I launch manage.py test, the fixtures from the 
> migration are created on the "production" database and not on the test_* 
> database.
>
> Is there a way to solve this issue ? Is this a known issue or nobody has 
> this problem ?
>
> Here is the migration
>
> # -*- coding: utf-8 -*-
> from __future__ import unicode_literals
>
> from django.db import models, migrations
>
>
> def create_bars(apps, schema_editor):
>     Bar = apps.get_model("foo", "Bar")
>     db_alias = schema_editor.connection.alias
>     Bar.objects.using(db_alias).bulk_create([
>         Bar(label="AAA"),
>         Bar(label="BBB")
>     ])
>
> class Migration(migrations.Migration):
>
>     dependencies = [
>         ('foo', '0001_initial'),
>     ]
>
>     operations = [
>         migrations.RunPython(create_bars),
>     ]
>
>
> 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/71ae45b7-3f74-4e93-ae3c-0935da4c7742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to