我使用两个数据库。我的基本是postgres数据库,而secound是mongodb。我的项目运行正常但是当我运行测试时: 我的配置 - 当我评论default_mongo然后测试运行良好:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'TEST_NAME': 'my_test_sql',
'TEST_USER': 'test_sql_user',
'TEST_PASSWORD': 'password'
},
'default_mongo': {
'ENGINE': 'django_mongodb_engine',
'NAME': 'bid',
'USER': '',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '27017',
'SUPPORTS_TRANSACTIONS': False,
'TEST_NAME': 'my_test_mongodb',
'TEST_USER': 'test_mongo_user',
'TEST_PASSWORD': 'password'
},
}
./ manage.py test
$ ./manage.py test
Creating test database for alias 'default'...
Destroying old test database 'default'...
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 71, in execute
super(Command, self).execute(*args, **options)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 88, in handle
failures = test_runner.run_tests(test_labels)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/test/runner.py", line 147, in run_tests
old_config = self.setup_databases()
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/test/runner.py", line 109, in setup_databases
return setup_databases(self.verbosity, self.interactive, **kwargs)
File "/home/t/py/django/bid/src/venv/local/lib/python2.7/site-packages/django/test/runner.py", line 299, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
TypeError: create_test_db() got an unexpected keyword argument 'serialize'