>
> One problem with this is that you have to be careful to write migrations
> that will always work from scratch. This is best practice, but I have on
> occasion used data migrations that were for specific problems, and may
> have depended on specific data in the database. I've also used them for
> populating parts of the database at specific upgrade points. Usually I
> wouldn't want this data to be installed for my tests - I want my tests
> to explicitly do the setup they need, and not be complicated by data
> from data migrations.
>
> For these reasons, and because of the slowness of running all the
> migrations, there are some projects where I have a settings file for
> running the tests that excludes South from INSTALLED_APPS, which solves
> the problem nicely.
>
> The slowness problem can be fixed by squashing, but it seems a shame to
> require that simply for the sake of running tests. And it doesn't solve
> the other problems. I would like to be able to turn off migrations for
> tests, and just skip to the final schema.
>

 Yes, this has traditionally been a problem, and it's difficult to say what
to do here.

I personally have the opinion that stuff you add in data migrations
_should_ be part of the tests - after all, it's usually crucial data that
the site won't work without, and you're never going to test an installation
without them.

However, I understand people don't like doing this. Problem is, the
alternative is to reserve the old syncdb method for running tests, and then
to introduce a new setting (which in South is SOUTH_TESTS_MIGRATE) that
lets users turn it on and off, which seems like a bad road to go down.

I'd rather keep it so you must run migrations for tests - as I believe we
should be making people do this as a general case - and if you want, having
the data migration operations have an option you can pass where they no-op
during tests, something like:

operations = [
    Python(
        """
        for author in Author.objects.all():
            author.fix()
        """,
        skip_during_tests=True,
    ),
]

Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to