Disable Django South when running unit tests? How do you avoid running all of the south migrations when doing django unit testing?
Asked
Active
Viewed 4,818 times
41
-
I am wondering why this matters? It is running this migrations on a test database when performing tests. Though if you remove `south` from INSTALLED_APPS you can prevent running its tests. – Torsten Engelbrecht Apr 27 '11 at 02:21
-
1@Torsten I have a use case that requires this: I have a 3rd party module that has a model with ForigenKey to my `User` class. However, I have a custom pk field in my `User`. Hence, when I run a test and the `0001_initial` migration for this 3rd party module runs, it creates a constrain in the test database with the wrong field name to the `user` table. This is why I need to turn migrations off when I run unit testing. – OrPo May 27 '13 at 09:23
2 Answers
68
Yes, the South documentation describes how to do it, but basically just add this to your settings.py file:
SOUTH_TESTS_MIGRATE = False # To disable migrations and use syncdb instead
SKIP_SOUTH_TESTS = True # To disable South's own unit tests

Andrew C
- 3,560
- 1
- 23
- 24
-
This will not disable south from running migrations, it only presents south from running its own unittests. See kiddouck's post on how to disable all south migrations when doing django unit testing. – Philip Clarke Sep 20 '11 at 15:20
31
Even though, you have selected the good answer, I think that you should consider the option SOUTH_TESTS_MIGRATE instead. It will prevent to run all the migrations on your test db, and run syncdb
instead.

kiddouk
- 421
- 3
- 4