Run Django tests in the main database
Recently I started working on a Django project, loaded the prod database into it, and ran the tests. Then the data was gone. I know some people intentionally want to run tests on the "main database", and there is a very simple way to achieve this.
Simply inherit from a test class that doesn't wrap your db interactions in transactions or puts them on a different test database. Then the database in the settings will be used.
import unittest
class YourDjangoTest(unittest.TestCase):
pass
0 comments
Reply