Running django tests with sqlite

前端 未结 4 561
孤城傲影
孤城傲影 2020-12-29 03:13

I use Postgres for production and development, but I\'d like to use sqlite to run some tests. I don\'t see an easy way to configure one engine for tests and another for dev

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 03:19

    Append the following lines in your settings:

    import sys
    if 'test' in sys.argv or 'test_coverage' in sys.argv: #Covers regular testing and django-coverage
        DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
    

    Make sure your actual database setting comes before them.

提交回复
热议问题