Missing Table When Running Django Unittest with Sqlite3

前端 未结 12 1793
半阙折子戏
半阙折子戏 2021-01-03 23:42

I\'m trying to run a unittest with Django 1.3. Normally, I use MySQL as my database backend, but since this is painfully slow to spinup for a single unittest, I\'m using Sql

12条回答
  •  执笔经年
    2021-01-04 00:05

    Your table didn't find in database by doing unittest, because unittest inherited unittest.TestCase. Wherein don't apply migrations to your database.

    If you want to use database with changes from migrations, then you should inherited test case class (for example) from django.test.TestCase.

    Run python manage.py test -v 3 and you will see applaying migrations to default testing database.

    More information to: https://docs.djangoproject.com/en/dev/topics/testing/overview/#the-test-database

提交回复
热议问题