Running django tests with sqlite

前端 未结 4 578
孤城傲影
孤城傲影 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:18

    I would suggest using -k or --keepdb -Flag when running manage.py test and the following setting:

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'DBNAME',
            'USER': 'DBNAME',
            'PASSWORD': 'DBNAME',
            'HOST': 'localhost',
            'PORT': '',
            'TEST': {
                'NAME': 'DBNAME_test',
            }
        },
    }
    

    In my setup with Django==1.11 it works like a charm. Good luck for yours!

提交回复
热议问题