Does anyone know a way to test the migration itself after writing it? Very many times in my DataMigrations I’ve found stupid subtle bugs, like True instead of False for the default value, wrong denormalizations, etc.
The default South convention is to start the migrations with numbers, so you can’t even import them without using __import__. Has anyone came up upon a similar problem? How do people solve them?
The most obvious approach would be to hold the migration logic in a separate imported module and test that, but that’s somewhat clunky.
I stumbled into the same problem. Since I didn’t find a way to do tests for datamigrations, I used assertions to detect corrupt data:
Ok, it’s a bit clunky. But it seems to work.
[Edit]
Thinking about it again, I found a much better solution: put the tests into the DataMigration itself. Since a migration is one-off code, it doesn’t have to be tested over and over.