Django, Multiple Test Files and Database Not Resetting

As per the new options for organizing tests, I put my tests for an app into a folder called tests. When I ran each test individually, each test worked. But when I ran all of them for that app together, one failed because the database was not resetting.

It turns out that the problem was due to my used of the test class SimpleTestCase and using mommy to make model instances. As the docs clearly point out, SimpleTestCase should not be used if you are using the ORM. Switching to TestCase solved the problem.

Being a good Django citizen, I looked into opening a ticket for this. Looks like someone else already did it. I am using Django 1.7. This ticket was completed around June 2015, so it’s not in 1.7


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s