Search code examples
pythondjangodjango-testing

Loading SQL dump before running Django tests


I have a fairly complex Django project which makes it hard/impossible to use fixtures for loading data.

What I would like to do is to load a database dump from the production database server after all tables has bene created by the testrunner and before the actual tests start running.

I've tried various "magic" in MyTestCase.setUp(), but with no luck.

Any suggestions would be most welcome. Thanks.


Solution

  • You may need to look into defining a custom test runner. There's some info here: https://docs.djangoproject.com/en/dev/topics/testing/advanced/#other-testing-frameworks

    Basically I think you can just copy the default test runner from django.test.simple.run_tests and then modify it to suit your needs.

    I've not done this before, but from my understanding that would be the way to customize this.