Specify Django Test Database names in settings.py

前端 未结 1 505
予麋鹿
予麋鹿 2020-12-17 08:47

I\'m specifying the databases using a python object:

DATABASES = {
 \'default\':{
   \'ENGINE\':\'mysql\',
   \'NAME\':\'testsqldb\',
   \'USER\':\'

        
相关标签:
1条回答
  • 2020-12-17 09:16

    In Django 1.6 and below, TEST_NAME should be a key of one of your database dictionaries. But in Django 1.7 and above, you use a TEST key which is a dictionary of settings for test databases.

    You probably want:

    DATABASES = {
     'default':{
       'ENGINE':'mysql',
       'NAME':'testsqldb',
       'USER':'<username>',
       'PASSWORD':'<password>',
       'TEST': {
           'NAME': 'auto_tests',
       }
     },
     'dynamic_data':{
       'ENGINE': 'sqlite3',
       'NAME':'',
       'USER':'',
       'PASSWORD':''
     },
    }
    

    Alternatively, perhaps you are wanting to use a different engine for your tests? In that case, I think you'll just have to create a separate settings file for testing. It can import from your standard settings module and override DATABASES.

    0 讨论(0)
提交回复
热议问题