How can I specify a database for Django Tests to use instead of having it build it every time?

后端 未结 2 1646
离开以前
离开以前 2020-12-03 08:10

I want to be able to use an existing test database to run my tests against and not have Django create and delete a database every time I want to run the tests. Is this possi

2条回答
  •  醉酒成梦
    2020-12-03 08:51

    Who are using Django >= 1.8

    python manage.py test --keepdb
    

    --keepdb Preserves the test database between test runs. This has the advantage of skipping both the create and destroy actions which can greatly decrease the time to run tests, especially those in a large test suite. If the test database does not exist, it will be created on the first run and then preserved for each subsequent run. Any unapplied migrations will also be applied to the test database before running the test suite.

提交回复
热议问题