Running django tests with sqlite

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

    You could try a setup similar to what is suggested here by Zachary Voase: http://blog.zacharyvoase.com/2010/02/03/django-project-conventions/

    (The entire post is useful, but scroll down to the section on "Settings" for the part most relevant here.)

    Zach's strategy is to create a settings folder and marks it as a python package using a __init__.py file. You can then have a separate sub-module for each of your deployment types, structured as follows:

    settings/
    |-- __init__.py     # Empty; makes this a Python package
    |-- common.py       # All the common settings are defined here
    |-- development.py  # Settings for development
    |-- production.py   # Settings for production
    |-- staging.py      # Settings for staging
    

    Following this concept, you could set up a deployment for postgres and a separate deployment for sqlite, and separate the configurations for each as needed.

提交回复
热议问题