Currently when I run a set of unit-tests on Django, each test makes its own database. This means that traversing multiple features of the site all require a user sign up, login, etc.. It would be much simpler if they all fetched from the same temporary database – anyway to do this?
Share
This is the default behavior of Django’s transactional test case to perform a rollback after each test.
There is nothing preventing you, though, to have a module function, test case method or to override
TestCase.setUp()to dynamically create test data. In fact, whenever you find yourself duplicating code, like creating the user and signing in with his credentials with the test client, you should find a way to make those bits reusable across your project’s test cases.