用sqlite运行django测试 [英] Running django tests with sqlite

查看:127
本文介绍了用sqlite运行django测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Postgres进行生产和开发,但是我想使用sqlite来运行一些测试。我没有看到一个简单的方法来配置一个引擎进行测试,另一个用于开发/生产。我错过了什么吗?

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 / production. Am I missing something?

推荐答案

在您的设置中附加以下行:

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.

这篇关于用sqlite运行django测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆