I'm experiencing the same problem as with: django - "manage.py test" fails "table already exists"
The schemamigration / migration worked fine (although did have some problems that required me to --fake, but all subsequent migrations with south work). But when I run a unit test I get:
(1050, "Table '{tablename}' already exists")
I'm just curious how I can get round this, and why this happens. The only answer given in the question linked above was that south could be excluded from unit tests, if I do this does it mean I can't unit test with tables managed by south?
Explanations much appreciated :)
Adam
No, it doesn't mean that. Don't forget that Django already knows what your tables should look like if you create them from scratch now - it just uses the model definitions. South is useful because it allows you to easily transform your table structure when you change your models, but when you're running tests you don't care about that: you just want the tests run on the current versions of the tables.
So yes, disable South when running tests, via SOUTH_TESTS_MIGRATE = False
, and Django will automatically create the tables for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With