[Django]-Why does my django test suite fail to refresh the database between tests when I alter my table during a test?

3👍

I suspect from stepping down into TestCase that my change is preventing the transaction rollback at the end of the test somehow, but I’m not really sure how yet or what to do about it.

I think that’s it. I would suggest moving to TransactionTestCase, which does not use transactions for resetting the database.

Why would transactions be messed up in your case? Bearing in mind that these things keep changing, this answer (by user joeforker) indicates that MySQL, which you use, treats instructions that alter schemas as “caus[ing] an implicit commit”, which would definitely mess up what TestCase expects. So your alter table command would “pull the rug” (so to speak) from under the feet of TestCase.

👤Louis

Leave a comment