Different db for testing in Django?

后端 未结 8 2040
轻奢々
轻奢々 2020-12-04 15:12
DATABASES = {
#    \'default\': {
#        \'ENGINE\': \'postgresql_psycopg2\',
#        ...
#    }

    # for unit tests
    \'default\': {
        \'ENGINE\': \'dj         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 15:57

    In your settings.py (or local_settings.py):

    import sys
    if 'test' in sys.argv:
        DATABASES['default'] = {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': 'mydatabase'
        }
    

提交回复
热议问题